Ok sure, here's my telling...
<CFIF CGI.Server_Name CONTAINS "companyname.com">
<CFSET SetDomain = "Y">
<CFSET SubDomain = Find(".", CGI.Server_Name, 1)>
<CFSET DocDomain = Mid(CGI.Server_Name, SubDomain + 1, Len(CGI.Server_Name))>
</CFIF>
<head>
<CFOUTPUT>
<SCRIPT LANGUAGE="JavaScript">
<!--
function populateData() { //This function is executed onload of page
<CFIF SetDomain IS "Y">
document.domain = "#CGI.Server_Name#"; //Output is "travel.companyname.com"
</CFIF>
//Passing large amount of text (over a few thousand
characters) into this modal dialog from parent (that opens this dialog), as
passing large amount of data thru URL parameters from parent will crash
var parentWindow = dialogArguments;
var bigContent = parentWindow.document.formName.TextContent.value;
document.all.id_Content.innerHTML = bigContent;
<CFIF SetDomain IS "Y">
//Need to set domain back to "companyname.com".
document.domain = "#DocDomain#"; //Output is "companyname.com"
</CFIF>
//Alerts in the scripts following won't work if I don't set document.domain
back to "companyname.com".
}
function customFunction_1() {
//Alerts in this function won't work if I don't set document.domain back to
"companyname.com" in populateData().
}
function customFunction_2() {
//Alerts in this function won't work if I don't set document.domain back to
"companyname.com" in populateData().
}
// -->
</SCRIPT>
</CFOUTPUT>
</head>
<body onload="populateData() ">
<table>
<tr>
<td>Display Data from Parent Page:</td>
<td id="id_Content"></td>
</tr>
</table>
<!--- customFunction_1() and customFunction_2() are executed somewhere below
this table; i'm not going to list it all. --->
</body>
BKBK - 28 Jul 2007 09:10 GMT
It seems like your fix avoided the problem rather than solve it. Two
suggestions:
1) <SCRIPT LANGUAGE="JavaScript"> is deprecated in current HTML. Use <SCRIPT
TYPE="text/javascript"> instead. However, that is not the cause of the problem.
What follows is.
2)document.domain is a standard Javascript variable to which the Javascript
engine automatically assigns a default value. To see that, open a page
containing just this code:
<script type="text/javascript">
alert(document.domain);
</script>
What you've been doing is forcing document.domain to take [i]your[/i] value.
What then happens is that it always reverts to the value assigned by the engine
at the earliest opportunity in the code. There are perhaps occasions when that
value is not "companyname.com".
The solution is simple, and it won't require you to change your script. Just
replace [i]document.domain[/i] by your own custom variable name, for example,
[i]myDomain[/i].
AppDeveloper - 29 Jul 2007 23:24 GMT
Ok sure, I'll implement your suggestions.
Thanks.