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
    New Coder
    Join Date
    Jan 2009
    Posts
    83
    Thanks
    4
    Thanked 0 Times in 0 Posts

    open popup window with image

    Hey guys,

    I need to make a image open a popup window, I know how to do it like this:

    function load2() {

    var load = window.open('pictures','','scrollbars=no,menubar=no,height=800,width=840,resizable=yes,toolbar=no,lo cation=no,status=no');

    }

    then on the link just have it go to javascript:load2()

    But I have a ton of different links and don't want a bunch of code in the beginning of my pages. Is there a way to make the first part just the dimensions of the new window but then when I actually make the link, I could put where I want it to link to? Like javascript:load2(pictures). or something like that?

  • #2
    Regular Coder
    Join Date
    May 2008
    Posts
    135
    Thanks
    13
    Thanked 10 Times in 10 Posts

    Post

    one way of doing it is

    firstly put all your js in an external file and include it on all the pages of site that require it, so then you can chop and change the code once, and it reflect across the site.

    Code:
    <script src="YOUR SCRIPT.js"></script>
    then i would write a standard function that takes the link as an argument.

    like so

    Code:
    function popUp(link){
        var window = window.open('pictures','','scrollbars=no,menubar=no,height=800,width=840,resizable=yes,toolbar=no,lo cation=no,status=no');
        var link = link
    
    //yada yada rest of code
    
    }
    then when you want to call it

    Code:
    <a href="#" onlclick="popUp('/img.jpg')> my link </a>

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    83
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks that worked!
    Last edited by rickfink; 06-23-2009 at 05:09 PM.


  •  

    Posting Permissions

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