SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member subtropical's Avatar
    Join Date
    Aug 2000
    Location
    St. Petersburg, FL
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    popup window dilemma

    First, I know zip about JavaScript. However, I was asked to create popup windows to come up when clicked. I'm sure this isn't the best way, but it was the only way I could figure out since I needed about 20 of these on the same page.

    Example:
    <a href="javascript:location='survey.htm';
    window.open('dialup.htm','Glossary',
    'height=250,width=300,scrollbars=no,menubar=no,toolbar=no,resizable=no,status=no')">Dial-up</a>

    They all work fine except when the user closes the popup window, they come back to the top of the main page. How can I make the main page stay put? I tried putting bookmarks into 'survey.htm', but that didn't work. If anyone can help me, I'd certainly appreciate it.

    P.S. - If I did this whole thing wrong, please excuse.
    Natalie

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The reason it snaps back to teh top is cause you've got: href="javascript:location='survey.htm';
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    SitePoint Member subtropical's Avatar
    Join Date
    Aug 2000
    Location
    St. Petersburg, FL
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jeremy - I realize that's the problem, but I don't know how to make it NOT go back to the top. I tried using bookmarks to make the page load back to the right place, but that didn't work.

    To further complicate the matter, the popups are different sizes. That's why I tried to do it in such a strange way.

    Is there a way, using this type of script, that I can make the original page stay put while the popups pop up and go away?
    Natalie

  4. #4
    SitePoint Member subtropical's Avatar
    Join Date
    Aug 2000
    Location
    St. Petersburg, FL
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please disregard last post. I found a local source who helped me figure out the problem.
    Thanks for your help.
    Natalie

  5. #5
    SitePoint Guru DenverDave's Avatar
    Join Date
    Feb 2001
    Location
    Denver, Colorado
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And the solution was ????

  6. #6
    SitePoint Member subtropical's Avatar
    Join Date
    Aug 2000
    Location
    St. Petersburg, FL
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    solution!

    It couldn't be done using the individual scripts for each window. They had me put the main pop-up script in the header and size each pop-up individually using the h and w variables as follows:

    Inside the <head> tags:
    <!-- hide javascript code from browsers that are not javascript enabled
    function openWindow(href, h, w){
    window.open(href,"Glossary","toolbar=no,status=yes,scrollbars=yes,menubar=no,resizeable=yes,width=" + w +",height=" + h);
    }
    //end hiding of javascript code -->

    Sample individual tag:
    <a href="javascript:" onClick="openWindow('cable.htm',250,300);">Cable</a>

    Hope it helps someone!
    Natalie

  7. #7
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks this did help me very much.

    One question tho, what is the "Glossary" part? Is it the page title? because it doesnt do anything for me.
    Wavelan

  8. #8
    SitePoint Member subtropical's Avatar
    Join Date
    Aug 2000
    Location
    St. Petersburg, FL
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hope someone will jump in and tell me whether my answer is right or wrong.

    My understanding is that when you aren't specifying one single URL to open as a popup, you put "href" in the head tag instead of the filename, allowing the script to find the file to open in the individual tags. Since the URL is supposed to be followed by a Name tag, I chose "Glossary" as the name because it summarized what all the popup windows on that page were about. It doesn't reference a particular page.
    Natalie

  9. #9
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Essentially, you are doing encapsulated JavaScript, even though you don't know it

    Instead of having one function for each window you have a single function and you pass information into the function, which then creates teh window for you.

    The Glossary thing is the window identifier, you're giving it a name that you can reference outside of that function, for instance:

    glossary.close();

    Would close the window, etc
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  10. #10
    SitePoint Member subtropical's Avatar
    Join Date
    Aug 2000
    Location
    St. Petersburg, FL
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jeremy!

    Sounds like I had the right idea, but my lack of terminology was showing!
    Natalie


Bookmarks

Posting Permissions

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