Forum Moderators: open
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 :)
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.
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?
<!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>
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 . . . "