Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Armondo's Avatar
    Join Date
    Feb 2007
    Posts
    144
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Javascript Po pup Help

    i need help with a javascript pop up...i have made this code:
    Code:
    <script type="text/javascript">
    var newwindow;
    function poptastic(url)
    {
    	newwindow=window.open(url,'name','height=550,width=400');
    	if (window.focus) {newwindow.focus()}
    }
    var newwindow2;
    function mp3pop(url)
    {
    	newwindow2=window.open(url,'name','height=50,width=760');
    	if (window.focus) {newwindow2.focus()}
    }
    </script>
    Code:
    i launch the popup with this:
    <a href="javascript:poptastic('../linkus.php');".... 
    and the second:
    <a href="javascript:mp3pop('../mp3pop.php');".....
    the second block in red is a second pop up i want to make. this all works fine, but is there a way i can make the height and width a variable inside of the link so i can just use one re-usable code block? thanks anyone who helps .

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    function mp3pop(url, height, width)
    {
    newwindow2=window.open(url,'name','height='+height+',width='+width);
    if (window.focus) {newwindow2.focus()}
    }

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Regular Coder Armondo's Avatar
    Join Date
    Feb 2007
    Posts
    144
    Thanks
    3
    Thanked 0 Times in 0 Posts
    oh, thanks buddy. i thought of making the stuff in the url thingy but never figured it out. and could you explain what you did? it works, i just want to know why. thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •