www.webdeveloper.com
Results 1 to 3 of 3

Thread: Get iframe Url of failed page

Hybrid View

  1. #1
    Join Date
    Sep 2013
    Posts
    3

    Get iframe Url of failed page

    I would like to get the url of the iframe when the page fails to load. Everytime I try I keep getting the original url of the iframe not the url it tried to access but failed on. How would I achieve this ?
    Here is my current script:

    var url1 = document.getElementById("ifrim").src;

    alert(url1.toString());

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,325
    Only thing I can suggest :
    Code:
    iframe = document.getElementById("theIframe");
    iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
    url = iframeDoc.location || iframeDoc.URL;
    url will equal the URL of the iframe
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,325
    Also... if you get an error 404 page, you can test for a failed page load by
    Code:
    loadedOK = iframeDoc.body.innerHTML.indexOf("Error 404")>-1?false:true;
    where loadedOK is true, you have a loaded page otherwise false is a failed load.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

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

Posting Permissions

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



Recent Articles