Jason28 Posted June 4, 2008 Share Posted June 4, 2008 Hello, I would like to pass variables into an existing function. Here is a popup function that I like using: function openpopup(popurl) { winpops=window.open(popurl,"","width=650,height=493,scrollbars=yes") } and it is called up by using a link such as: <a href="terms.php" onclick="openpopup(this.href);return false">Terms</a My question is that can you give me a working example so that I can pass the height, width, and scrollbars vars from the link into the function? That way I can just pass those vars from different urls so I can have different size popups for each link. Thanks! Quote Link to comment Share on other sites More sharing options...
Jason28 Posted June 4, 2008 Author Share Posted June 4, 2008 Sorry an update, I want to use this other function instead of the first function I posted: function openWin() { win = window.open("test.php?action=view_users", "Window", "width=810,height=600,scrollbars=yes"); } Please let me know how to pass vars from a webpage into this function. Thanks! Quote Link to comment Share on other sites More sharing options...
kbh43dz_u Posted June 4, 2008 Share Posted June 4, 2008 function openWin(width, height, scroll){ //scroll = yes/no win = window.open("test.php?action=view_users", "Window", "width="+width+",height="+height+",scrollbars="+scroll); } <a href="terms.php" onclick="openWin("600", "400", "yes");return false">Terms</a (are you sure you don't want the url for the popup to be dynamic? in the "new" function you posted it will not be given to the function by your link) Quote Link to comment Share on other sites More sharing options...
Jason28 Posted June 4, 2008 Author Share Posted June 4, 2008 Thanks bud I got it to work Sorry one last simple question. One one link I used: onClick="javascript:goHide('div1'); go('div2')" However I assume there is a better way to write that instead of calling the same function twice? If not no big deal. Thanks! Quote Link to comment Share on other sites More sharing options...
kbh43dz_u Posted June 4, 2008 Share Posted June 4, 2008 There will be hardly any better way, except if it happens often that you want to hide more div's at the same thime -> than you could put all wanted divs in an array and give the array to your function. But also then the function does everything again for every div. So it will not be a big deal Quote Link to comment Share on other sites More sharing options...
Jason28 Posted June 4, 2008 Author Share Posted June 4, 2008 Ok great I wanted to make sure that wasn't the only way I checked out your site that is impressive that you are only 19 and already know so much plus married Quote Link to comment Share on other sites More sharing options...
kbh43dz_u Posted June 4, 2008 Share Posted June 4, 2008 thank you Quote Link to comment 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.