Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.