/    Sign up×
Community /Pin to ProfileBookmark

Need Help to understand browsers behaviors

Ok guys,

first of all, thanks for your interest on this thread. Let me try to explain what I am doing:

I have a html page that has an object (image, button, etc) that calls the following javascript function:

[CODE]
function executedByObject() {
newwin = window.open();
var htmlStringFinal = “<html><head><script language=’javascript’ src=’myJSFun.js’></script></head> n” +
“<body><script language=’javascript’>document.write(myString(1,1,1));</script></body></html>
newwin.document.open();
newwin.document.write(htmlStringFinal);
newwin.document.close();
}
[/CODE]

The document myJSFun.js is:

[CODE]
function myString(i,j,k) {
return “i = ” + i + ” j = ” + j + ” k = ” + k;
}
[/CODE]

No, when I execute the function “executedByObject()” the behavior is different depending of the 2 browser that I tried, both fail, but:

Mozilla FireFox 1.5: It opens the new window, prints the message on the screen, but it never load the page completely, I mean, it continuous loading. I try to find a JS code error, but I can’t find one. I also tried to open the page source, but nothing is displayed.

Internet Explorer 6.0: It opens the window but It return an error code on “myString” function. It cannot find it, but when I replace it but other an string, it works perfect.

Let me know if there is a work around to this problem, my priority is that the user should not be able to see how the returning string of myString is formed.

Any comment is welcome,

Jaime

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterDec 16.2005 — Give this a try:
<i>
</i>function executedByObject() {
newwin = window.open();
var htmlStringFinal = "&lt;html&gt;&lt;head&gt;&lt;script type='text/javascript' src='myJSFun.js'&gt;&lt;/script&gt;&lt;/head&gt; n" +
"&lt;body&gt;&lt;script type='text/javascript'&gt;document.write(myString(1,1,1));&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;";
newwin.document.open();
newwin.document.write(htmlStringFinal); <br/>
newwin.document.close();
}

#1 JavaScript understands the following
<i>
</i>&lt;script&gt;
alert("&lt;/script&gt;")
&lt;/script&gt;

as:
<i>
</i>&lt;script&gt;
alert("
&lt;/script&gt;
")&amp;lt;/script&amp;gt;


#2 the string htmlStringFinal lacks a closing quote after </html>
Copy linkTweet thisAlerts:
@jbarraganauthorDec 19.2005 — I tried your solution, it is a clean way to write closing tag in javascript strings, I didn't know and I find it very useful "</tag>". But after trying it, I am still having the same problems. I opened a new tag trying to explain better this issue. You or any person interest on the topic can get a better idea on the following link: http://www.webdeveloper.com/forum/showthread.php?t=88863

Thanks again,


Jaime
×

Success!

Help @jbarragan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...