Jump to content
xisto Community
Sign in to follow this  
gunbound

[help] Java Script: Window.open Works with Firefox, not IE

Recommended Posts

<HEAD>var popUpWin=0;function popUpWindow(URLStr){  if(popUpWin)  {    if(!popUpWin.closed) popUpWin.close();  }  popUpWin = open(URLStr, 'GunBound Tactics: Screenshots', 'width=820,height=550,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,top=90,left=90');}</HEAD><BODY><a href="javascript:popUpWindow('/f11/clipped.php');"><b>Clips</b></a>
</BODY>

This is a script for opening a new window. It works with Firefox and not Internet Explorer. IE gives a script error and it references a part of the code that has nothing to do with the script. Someone please tell me if you can figure out why.

Used at this address

I'm not asking your opinion about IE and FF. Just help me fix it if you can. Thanks.

Share this post


Link to post
Share on other sites

Sorry, something went wrong with that post. The ' is supposed to be a ', and </BODY> is supposed to be in the code tag.

 

Additional note: this script came from DreamWeaver MX 2004

 

I'd appreciate if someone would fix this and delete this second post.

Share this post


Link to post
Share on other sites

I wrote this script for use in a few past projects, and it has worked fine for me ever since, maybe it will suit your needs as well?

function OpenSubWin( page, w, h, sb ){  var sw = screen.width, sh = screen.height;   var ulx = ((sw-w)/2), uly = ((sh-h)/2);   var sbt = (sb==1) ? 'yes' : 'no';   var paramz = 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars='+sbt+',width='+w+',height='+h+'';   var oSubWin = window.open( "", "SubWin", paramz );   oSubWin.moveTo( ulx, uly );   oSubWin.location.replace( page );}

The parameters it accepts are:
page --> the URL to the page to open
w --> the Width of the Sub-Window
h --> the Height of the Sub-Window
sb --> if 1 then display Scrollbars in Sub-Window (could be set to 0, or auto)

It even centers the Sub-Window for you too..

Example usage:
<a href="javascript:OpenSubWin( 'my_page.html', 640, 480, 1 );"> Click Here.. </a>

I hope that helps!

Share this post


Link to post
Share on other sites

Sorry for double-post, but the Code tags messed up my script above, you should replace the & # 39 ; with a single-quote to fix the script I posted..

Share this post


Link to post
Share on other sites

Ewww Dreamweaver.
That being said, here is the code that works for me. I find it very nice and simple.

<head><script language="JavaScript"> <!--function FUNCTION1(){window.open('WEBPAGEADDRESS.html','mywindow','width=500,height=500,toolbar=no,menubar=no,scrollbars=no,resizable=no');}//--> </script></head><body><a href="javascript:FUNCTION1()">TEXT</a></body>

You can replace WEBPAGEADDRESS with any webpage. (main.html, index.html, https://www.google.de/?gfe_rd=cr&ei=7AkjVIatDsKH8QfNkoC4DQ&gws_rd=ssl)

If you had wanted two links on the page then your code would look like this.
<head><script language="JavaScript"> <!--function FUNCTION1(){window.open('WEBPAGEADDRESS.html','mywindow','width=500,height=500,toolbar=no,menubar=no,scrollbars=no,resizable=no');}//--> <!--function FUNCTION2(){window.open('WEBPAGEADDRESS.html','mywindow','width=500,height=500,toolbar=no,menubar=no,scrollbars=no,resizable=no');}//--> </script></head><body><a href="javascript:FUNCTION1()">TEXT</a><a href="javascript:FUNCTION2()">TEXT</a></body>

Hope thats clear.

Share this post


Link to post
Share on other sites

<HEAD>var popUpWin=0;function popUpWindow(URLStr){  if(popUpWin)  {    if(!popUpWin.closed) popUpWin.close();  }  popUpWin = open(URLStr, 'GunBound Tactics: Screenshots', 'width=820,height=550,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,top=90,left=90');}</HEAD>
You've left out the <script type="text/javascript"> & </script> tags.

Share this post


Link to post
Share on other sites

I think what you are missing is the <script> tags as Tyssen mentioned above and you should also add the 'window' part to call the open window like all the other examples other members have given. eg. popUpWin = window.open();

 

Also, the opened window name ('GunBound Tactics: Screenshots') should only contain alphanumeric characters (A-Z, 0-9) or underscores (_). Although, I doubt that would be causing the problem.

 

Notice from snlildude87:
Edited
Edited by snlildude87 (see edit history)

Share this post


Link to post
Share on other sites

"GunBound Tactics: Screenshots" is your window name, not your title of the window.IE only let you use alphabet and _.you should have something like "newwin" insted.then use document. write ... <TITLE>...</TITLE> to add title.-deluxmilkman

Share this post


Link to post
Share on other sites

parse parameter when open new window

[help] Java Script: Window.open

 

Page that I create to open a new window already done, but it cannot parse parameter. Where should I put a parameter? jsp or java. Before that in parent window I have filter the value by pttName and month and output display. So I want to bring this 2 parameter to child window.

 

Below its code that I have done.

 

Page1.Jsp

Function prntLetter()

{

var url = "ReportBirthdateNameList.Jsp";

var name = "pageLetter";

var features = "toolbar=0,location=0,directories=0,status=0, menubar=0,copyhistory=no,scrollbars=yes,resile=no";

window.Open(url,name, features);

}

</script>

 

Button code:

<input type="button" name="btnLetter" value="Print Name & Address" onclick="prntLetter()">

 

 

 

-question by miedah

Share this post


Link to post
Share on other sites

Adding a Feature

[help] Java Script: Window.open

 

Replying to SystemWisdom

 

I had a suggestion to add to SystemWisdom's code. It works great for a single popup, however, by adding this line:

 

if(window.Focus){ oSubWin.Focus() }

 

The popup will retain focus upon clicking multiple links

(For example in a photo gallery... See http://forums.xisto.com/no_longer_exists/)

 

===> http://forums.xisto.com/no_longer_exists/ if that isn't yet updated.

 

-reply by ClemsonWaterski

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.