Jump to content

New window issue


sazzie

Recommended Posts

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] :P

Where constructCalendar() is my javascript function. By the way, my web pages are php scripts.

:D
Link to comment
https://forums.phpfreaks.com/topic/35342-new-window-issue/
Share on other sites

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();
}
Link to comment
https://forums.phpfreaks.com/topic/35342-new-window-issue/#findComment-167041
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/35342-new-window-issue/#findComment-170895
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/35342-new-window-issue/#findComment-170924
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.