Forum Moderators: open

Message Too Old, No Replies

java script popup wont work in IE

java script popup wont work in IE

         

tj1990

4:28 am on Nov 20, 2009 (gmt 0)

10+ Year Member



hello i use got this code from a java website, and when i open the popup in any browser except IE it works fine

popup in IE
[i45.tinypic.com...]

Popup in Safari or any other browser
[i46.tinypic.com...]

this is the code i use

<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Idea by: Nic Wolfe -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source! [javascript.internet.com...] -->

<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=580,height=360,left = 410,top = 230');");
}
// End -->
</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<A HREF="javascript:popUp('popup.html')">Open the Popup Window</A>

</body>
</html>

the popup window just loads an embedded youtube video, what do i need to change to make it work in IE?

Thanks :)

Fotiman

3:58 pm on Nov 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



First, welcome to WebmasterWorld! :)
If the popup window comes up, then I don't think the problem is with the code that opens the popup, but rather with your code on the popup.html page. If you enter the URL of the popup.html page into IE, does the video display?

rocknbil

6:40 pm on Nov 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Agreed, but the best resolution for cross browser Flash issues I've found is swfObject [code.google.com]. It's really easy to implement, should only take an hour or so to get it working.

webmaster world samples [google.com]

Couple changes though, to bring your script up to date:

<SCRIPT LANGUAGE="JavaScript">

change to

<script type="text/javascript">

Do not use eval, it's not needed here. Eval is for evaluating numeric expressions, and although it works is not necessary.

For window attributes, "=0/1" is not needed. Just include the attribute if you want it, leave it out if you don't. On that topic, you never want to eliminate the scrollbars and resizable attributes, it may "fit perfect" in your environment but you never know what your end users will experience. Nothing more frustrating than not being able to access vital controls, such as close button or submit button, because they are stuffed below the edge of a non-resizable window without scrollbars.

Return false from your function, and include a **real** URL in the href so if JS is disabled your content can still be accessed. What return false does is tells the browser to not execute the natural action, navigate to the link. This makes your page accessible.

full revision:


<script type="text/javascript">
function popUp(URL) {
day = new Date();
id = day.getTime();
params = 'scrollbars,resizable,width=580,height=360,left=410,top=230';
var win = window.open(URL,id,params);
return false;
}
</script>

<a href="popup.html" onClick="return popUp('popup.html');">Open the Popup Window</a>

Check it out, turn off JS, it will work in both cases.

tj1990

11:17 pm on Nov 22, 2009 (gmt 0)

10+ Year Member



Thank you Fotiman, and yes if i enter the URL into IE it works fine (its just a youtube video) although on the popup i use the embedded youtube video code for it, so maybe that is causing some issues for it?

and thank you rocknbil, i changed those few things in my code, but i now seem to be having trouble adding in scrollbar and making it resizable. i added =1 to scrollbar and resizable, is that what i was ment to do to make them work?

Fotiman

3:21 pm on Nov 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can you post the relevant code that appears in popup.html?

tj1990

10:54 pm on Nov 23, 2009 (gmt 0)

10+ Year Member



sure, here it is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/0RmApvCnoeo&hl=en_US&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/0RmApvCnoeo&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

</body>
</html>

rocknbil

2:42 am on Nov 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Move your code out of the <head></head> and into <body> (code here ) </body>

See previous link about SWFObject, although this code works, it is invalid HTML because <embed> is nested inside <object>. I know that's the way Flash and other applications do it, but it's still incorrect.

Sorry Fotiman, just happened to "be here . . . "

tj1990

3:53 am on Nov 24, 2009 (gmt 0)

10+ Year Member



i moved the code as you said rockinbil

and it now works in IE, thank you :)

and when i go to add some more videos i will look into the link about SWFObject, to save some issues.

Thank you all for you help :)

Fotiman

1:49 pm on Nov 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@rocknbil, no need to apologize. :) I'm always happy to see members helping each other.
@tj1990, gladd it's working for you.