SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: page redirect

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    page redirect

    I have a page that opens up a popup window after clicking a button. I want to test if the parent/previous page is a certain page when the popup window loads and if it is not then I don't want the popup window to open. I also want the page to redirect if a person just puts the popwindow address into their browser. I am working with asp.net vb and I am told javascript is the best way to do this. I know enough to open the popup window using javascript and that is about it.

    Any ideas?

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming you are using an external js file for more than one page

    Code:
    function popup(){
    if(location.href =='http://www.sitepoint.com')return false;
    window.open(...)
    }
    and the second question

    Code:
    if(!window.opener)location.href='http://www.sitepoint.com';

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I open my page using this:

    Code:
                Response.Write("<script language=JavaScript>window.open('page.aspx', 'null','width=700, height=600, menubar=no, left=25 top=10 status=no, scrollbars=yes, resizable=yes, toolbar=no, location=no');</script>")
    I don't understand how to check if the page is being opened by the parent page.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,872
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If your visitors have any sort of popup blocker installed then the page wont pop up at all using that code.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know that


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
  •