SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    May 2007
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing Frame Src

    Hello. I am trying to change frame src attribute of a web site with javascript according. Excerpt code is below.

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head>
    <
    title>Page</title>
    </
    head>


    <
    frameset id="main" rows="50,*" border="0">

    <
    frame name="bar1" src="menu.php"  />
    <
    frame name="bar2" src="category.php"  />

    </
    frameset>

    </
    html
    Now I have to change src attribute of bar2 to news.php. With an event listener ("load") added to window object, I can change the src element but this method first loads category.php and then redirects frame to news.php. All I want is to change src attribute to news.php before browser attempts to download any data of category.php. Is it possible to do so and how? I am asking this for a greasemonkey script, so it is a client-side problem.

    Thanks in advance.

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Greasemonkey scripts execute when the DOMContentLoaded event is triggered. Meaning once the DOM has been loaded (not including images, css etc).

    I am not sure that you can completely prevent the browser from starting to load category.php before you change its source with JavaScript.
    Last edited by Pepejeria; Mar 13, 2008 at 06:12.


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
  •