Main Page for show Modeless Dialog
/*
JavaScript Bible, Fourth Edition
by Danny Goodman
John Wiley & Sons CopyRight 2001
*/
<HTML>
<HEAD>
<TITLE>window.setModelessDialog() Method</TITLE>
<SCRIPT LANGUAGE="JavaScript">
var currPrefs = new Array()
var prefsDlog
function getPrefsData() {
if (!prefsDlog || prefsDlog.closed) {
prefsDlog = showModelessDialog("lst16-42.htm", setPrefs,
"dialogWidth:400px; dialogHeight:300px")
prefsDlog.init(currPrefs)
}
}
function setPrefs(prefs) {
if (prefs["bgColor"]) {
document.body.style.backgroundColor = prefs["bgColor"]
currPrefs["bgColor"] = prefs["bgColor"]
}
if (prefs["textColor"]) {
document.body.style.color = prefs["textColor"]
currPrefs["textColor"] = prefs["textColor"]
}
if (prefs["h1Size"]) {
document.all.welcomeHeader.style.fontSize = prefs["h1Size"]
currPrefs["h1Size"] = prefs["h1Size"]
}
if (prefs["name"]) {
document.all.firstName.innerText = prefs["name"]
currPrefs["name"] = prefs["name"]
}
}
function init() {
document.all.firstName.innerText = "friend"
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#eeeeee" STYLE="margin:20px" onLoad="init()">
<H1>window.setModelessDialog() Method</H1>
<HR>
<H2 ID="welcomeHeader">Welcome, <SPAN ID="firstName"> </SPAN>!</H2>
<HR>
<P>Use this button to set style preferences for this page:
<BUTTON ID="prefsButton" onClick="getPrefsData()">
Preferences
</BUTTON>
</BODY>
</HTML>
Related examples in the same category