Results 1 to 15 of 15

Thread: Javascript OnLoad

  1. #1
    OMG!! PWND!!
    Join Date
    Dec 2003
    Location
    In front of computer
    Posts
    964
    Thanks
    0
    Thanked
    0 times in 0 posts

    Javascript OnLoad

    Hey! Is it possible to make javascript do something when an iframe has finished loading?

    I have my page that loads up anotehr site in the Iframe, and I need it to know when the Iframe is loaded..

    Thanks in advance

  2. #2
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom
    You just need to know when it's loaded, or you want the onload event to trigger something in the parent window?

    And after the amount of problems I've had with iframes over the last couple of weeks, I'm going to take your legs away for using them.
    sig removed by Zak33

  3. #3
    OMG!! PWND!!
    Join Date
    Dec 2003
    Location
    In front of computer
    Posts
    964
    Thanks
    0
    Thanked
    0 times in 0 posts
    Lol!! They are a bit tough, but i like them

    Yeah, I just need to know when they have loaded.. Then want to run some script in the parent window, tat does stuff in the Iframe.. fun :S

  4. #4
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    <body onload="doSomethingToParent()">

    then a JS function

    function doSomethingToParent()
    {
    document.parent.whateveryouwanttodo;
    }

    as you may have guessed, if you can't tell us what you want to do it become pretty difficult to write code for it

  5. #5
    IBM
    IBM is offline
    there but for the grace of God, go I IBM's Avatar
    Join Date
    Dec 2003
    Location
    West London
    Posts
    4,187
    Thanks
    149
    Thanked
    244 times in 145 posts
    • IBM's system
      • Motherboard:
      • Asus P5K Deluxe
      • CPU:
      • Intel E6600 Core2Duo 2.40GHz
      • Memory:
      • 2x2GB kit (1GBx2), Ballistix 240-pin DIMM, DDR2 PC2-6400
      • Storage:
      • 150G WD SATA 10k RAPTOR, 500GB WD SATA Enterprise
      • Graphics card(s):
      • Leadtek NVIDIA GeForce PX8800GTS 640MB
      • PSU:
      • CORSAIR HX 620W MODULAR PSU
      • Case:
      • Antec P182 Black Case
      • Monitor(s):
      • Dell 2407WPF A04
      • Internet:
      • domestic zoom
    Applecrusher....they're not tough, they're just silly. And a pointless waste of time. Why add another level of complexity, especially when you're using a scripting language that you want to talk together? Is it because you think it loads faster? Or because you like that one page changes without changing the rest of the page?

    (Can you see that I've tried to rationalise using Frames prior to this rant?)

    It's all false. It's not faster, it's not nicer, it's just poo. Don't do it, it's not worth it...

    And if you're determined to stick with it, do what Iain said...
    sig removed by Zak33

  6. #6
    Uber Geek
    Join Date
    Sep 2004
    Location
    Leeds, W Yorks
    Posts
    598
    Thanks
    2
    Thanked
    4 times in 4 posts
    lol... I use iFrames for fast-looking searching... its not that it actually is faster or better, it just looks nicer to the end user.

    I'm using callbacks to an iFrame that runs SQL stored procs based on input in up to 3 boxes... looks lovely and mimics a true application much better - I program for idiots, so we need to make it behave as simply as possible. The less buttons etc they need to press, the better. iFrames are just nice because I set them to invisible via css

    And yes:

    parent.functionName()

    works fine

  7. #7
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    If the only reason you're using iframes is so you can hide them from the user then just use a div and set to to have an x and y position in the negative, i.e. outside the browser window. If it needs to run SQL stored procs without refreshing the page then use and XMLHTTP request in the same way as I've done on the search box on the main HEXUS site. Just type in a search and once you've entered 3 characters it starts predicting the results using an XMLHTTP call to the database. Dead easy to implement and infinitely better than iframes

  8. #8
    OMG!! PWND!!
    Join Date
    Dec 2003
    Location
    In front of computer
    Posts
    964
    Thanks
    0
    Thanked
    0 times in 0 posts
    Quote Originally Posted by Iain
    <body onload="doSomethingToParent()">
    I cant do that, as i dont have control over what is in the Iframe

    What I am aiming to do it have my Iframe help me with online games, it goes and does little things for me, but for these games, I cant edit the pages (obviously), so i need my page to know when the Iframe has loaded...

    And if someone can give me a better way to do this than with Iframes or frames, i would be greatful

  9. #9
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    Tell us the game site so we can see if there's any way to parse it's content

  10. #10
    OMG!! PWND!!
    Join Date
    Dec 2003
    Location
    In front of computer
    Posts
    964
    Thanks
    0
    Thanked
    0 times in 0 posts
    Quote Originally Posted by Iain
    Tell us the game site so we can see if there's any way to parse it's content
    www.darkthrone.com

    If you want to log in, add me to msn and ill lend you my old username and password

  11. #11
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    I created an account, which page is it you are trying to use ?

  12. #12
    Member
    Join Date
    Oct 2005
    Posts
    92
    Thanks
    0
    Thanked
    0 times in 0 posts
    One trick you could use would be to use something like setTimeout to keep looping until you find you can access the body tag through JavaScript.

    Code:
    function checkLoadState()
    if (iframe.window.body)
    {
        //Do whatever you need
    }
    else
    {
        setTimeout("checkLoadState()", 1000)
    }
    I've never tried looking for an element within the page i cannot control as my code checks for the state of a flag but this MIGHT work.

    Nick
    Abit IP-35 Pro, Core 2 Quad Q6600 @ 3Ghz, 8800GTS 512, Zalman Reserator1 External Watercooler, 4GB DDR2, 76GB Raptor 10k, 300GB Seagate Barracuda 7200.10, 2x Maxtor 250GB 7.2k, ViewSonic VP201s & Dell 2408

  13. #13
    OMG!! PWND!!
    Join Date
    Dec 2003
    Location
    In front of computer
    Posts
    964
    Thanks
    0
    Thanked
    0 times in 0 posts
    Quote Originally Posted by Iain
    I created an account, which page is it you are trying to use ?
    in the recruiter, I want to run the part function that enables the picture.. not quite legal, but meh

  14. #14
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    Error
    Due to players using automated programs which hurt our site, refreshing has been disabled. Please use the recruit! button on the recruiter. Click here to continue.
    I'm not going to help you break someone else's site by hammering their bandwidth.

  15. #15
    OMG!! PWND!!
    Join Date
    Dec 2003
    Location
    In front of computer
    Posts
    964
    Thanks
    0
    Thanked
    0 times in 0 posts
    Damn, that only just popped up too!! Arrgh!! And i thought I was the only one smart enough to think of this!! Ohh well.. I'll just do it the old fassioned way

    Thanks anyway

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Mixing Javascript with ASP in Overlib..
    By Stoo in forum Software
    Replies: 2
    Last Post: 13-09-2005, 07:21 AM
  2. javascript not displaying in firefox
    By ZigZag in forum Software
    Replies: 3
    Last Post: 11-09-2005, 12:05 PM
  3. Webpage: Live stock price (using javascript?)
    By Dihi Doctor in forum Software
    Replies: 3
    Last Post: 09-09-2005, 09:27 AM
  4. Replies: 1
    Last Post: 14-08-2003, 03:32 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
  •