Looking for help with JavaScript and Frames

Discussion in 'JavaScript' started by webdev11, Dec 20, 2007.

  1. #1
    I don't know JavaScript, but I'm trying to get an effect that I think can be done in JavaScript.

    I have dynamically-generated pages that each have a link to an external Web site. Each link should popup a new browser window with two frames -- a top frame from the originating site, and a lower frame with the external site... something like how about.com and propeller.com do it.

    It's not my idea, but this is the effect needed.
     
    webdev11, Dec 20, 2007 IP
  2. locdev

    locdev Active Member

    Messages:
    171
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #2
    You need to create a page with frames structure you need and use it instead of direct links. e.g.:
    http://yoursite.com/external.html?url=google.com

    external.html has a frame set and accepts the querystring url param which is used to load the frame.
     
    locdev, Dec 21, 2007 IP
  3. webdev11

    webdev11 Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply. Is there any security risk with doing that? (I could do it with PHP)

    Just verify that it's a valid URL?
     
    webdev11, Dec 21, 2007 IP
  4. BuildHome

    BuildHome Well-Known Member

    Messages:
    837
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    108
    #4
    If you can use PHP, you can do it using SESSION or QUERYSTRING in PHP for more security.
     
    BuildHome, Dec 21, 2007 IP
  5. locdev

    locdev Active Member

    Messages:
    171
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #5
    ya but some sites can load without your frames. It is possible with a tiny js function.
    and as you don't control the site code in one of your frames the -->"It's not my idea, but this is the effect needed." can't be 100% achieved.
     
    locdev, Dec 21, 2007 IP
  6. webdev11

    webdev11 Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What do you mean by QUERYSTRING? Do you mean just accept an external URL as a parameter in the frameset URL?

    sorry, I didn't understand completely. Are you saying that there is a security risk?
     
    webdev11, Dec 21, 2007 IP
  7. locdev

    locdev Active Member

    Messages:
    171
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #7
    No security risk. Frames are on the client-side.

    for example the code which loads without frames:
    <script language="JavaScript">if(parent.frames.length>=1 {window.top.location.href="index.html"}</script>

    just put it in the header section, replace "index.html" and you will be free of any frames :)
     
    locdev, Dec 21, 2007 IP
  8. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I can write you a PHP code that will do that PM me if you want it it's free BTW :D
     
    chriswick, Dec 22, 2007 IP