sazzie Posted January 23, 2007 Share Posted January 23, 2007 Can anyone tell me if it is possible to open a new window with a javascript function call as the argument i.e :[code] <a href="#" onClick=window.open('constructCalendar()');>Click for calendar</a> [/code] :PWhere constructCalendar() is my javascript function. By the way, my web pages are php scripts. :D Quote Link to comment https://forums.phpfreaks.com/topic/35342-new-window-issue/ Share on other sites More sharing options...
paul2463 Posted January 23, 2007 Share Posted January 23, 2007 function PopupMe(num){myleft=(screen.width)?(screen.width-800)/2:100;mytop=(screen.height)?(screen.height-600)/2:100;settings='top=' + mytop + ',left=' + myleft + ',width=500,height=400,location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=no,fullscreen=no, titlebar=no'var address = "";switch(num) { case 1: address = 'url to help.php'; break; case 2: address = 'url to other help.php'; break;}Login=window.open(address,'Login', settings);Login.focus();} Quote Link to comment https://forums.phpfreaks.com/topic/35342-new-window-issue/#findComment-167041 Share on other sites More sharing options...
bibby Posted January 28, 2007 Share Posted January 28, 2007 yeah, don't put your function call in window.open, (!) window.open('[b]constructCalendar()[/b]')call a different function that does both.onclick="launch()"function launch should then call window open.What does construct calendar do? Is it something that the destination page should handle instead? Because once that window's open, there's only so much you can do with it from here. Quote Link to comment https://forums.phpfreaks.com/topic/35342-new-window-issue/#findComment-170895 Share on other sites More sharing options...
mainewoods Posted January 28, 2007 Share Posted January 28, 2007 you can use a function as a parameter to a function but leave off the quotes:[code]window.open(constructCalendar());[/code]'constructCalendar()' would execute in the current page - not the target page.--the only way the code above could be correct is if 'constructCalendar()' is returning the parameters of the window.open() function! No other return values would be valid in that context.--what you probably want is for the 'constructCalendar()' to execute in the new window when the target page loads. Put a onload in the body tag of the target page:[code]<body onload="constructCalendar();">[/code]--the target page will of course also have to have the 'constructCalendar()' function defined in the HEAD section of the document. Quote Link to comment https://forums.phpfreaks.com/topic/35342-new-window-issue/#findComment-170924 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.