Forum Moderators: open

Message Too Old, No Replies

pop-up window display in Internet Explorer

         

sreedevi2006

6:06 am on Jun 2, 2006 (gmt 0)

10+ Year Member



In IE browser,for pop-up window display if I specify the name argument with spaces I get an error stating that it is an invalid argument. But the same thing works for Mozilla Firefox. Is there any workaround for IE browser?

<html>
<head>
<title>
Pop-up Window
</title>

<script>
function dispPop()
{
features="height=400,width=500,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,top=200,left=200";
window.open("pop.html","a b c;",features);
}
</script>
</head>
<body>
<input type="button" onclick="dispPop();" value="pop-up"/>
</body>
</html>

birdbrain

7:39 am on Jun 2, 2006 (gmt 0)



Hi there sreedevi2006,

change this...


"a b c;"

...to this...


"a_b_c"

...both the space and the semi-colon will cause IE to fail.

coothead

sreedevi2006

2:26 pm on Jun 2, 2006 (gmt 0)

10+ Year Member



Thanks for the reply.

I just thought the escape method might also help.
The escape() method returns an encoded format of the input string.
if i use escape("a b c"), it doesn't work either.
it encodes "a b c" to a%20b%20c
Is it that the name parameter in pop-up doesn't accept even the encoded format?

birdbrain

10:36 am on Jun 3, 2006 (gmt 0)



Hi there sreedevi2006,

well you do it like this...


<script type="text/javascript">
<!--
function dispPop() {
nme='a b c';
nme=nme.replace(/\s/g,'_');
features="height=400,width=500,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,top=200,left=200";
window.open("pop.html",nme,features);
}
//-->
</script>

birdbrain

rocknbil

4:37 pm on Jun 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you think of it as a variable it makes sense. No spaces in vars either. :-)

The use of the window name should be unique. This is what it's for. This insures any new windows are indeed new instead of popping content into an existing one.

Scenario: two pop-up links on a page. User clicks one, new window with name a_b_c opens. User clicks back in main window, which puts a_b_c behind main window. User clicks link 2 and content loads in a_b_c, which is BEHINd the main window, unseen to the user, and their impression is likely "This site sucks, the link is broken!"

By assigning a unique identifier every time you open a new window, it will always open a NEW window:

var day = getDate();
var id = day.getTime();

var win = open(url,id, 'width=450,height=450,scrollbars, resizable');

Note also that yes and no are not required, either include the attribute or not.