Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1024977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:51:27+00:00 2026-05-16T11:51:27+00:00

I found a JavaScript error in a script that I’m developing. I whittled it

  • 0

I found a JavaScript error in a script that I’m developing. I whittled it down to a pair of fairly concise pages that still produce the error:

  • http://troy.onespot.com/static/4505/index.html
  • http://troy.onespot.com/static/4505/iframe.html

If you load the first page in Internet Explorer 8 (or probably 6 or 7, for that matter), give it about half a second to run the script, then click the “Google” link inside of the <iframe>, you should see an error message appear:

http://skitch.com/troywarr/dui21/ie8-error

(You may need to uncheck Tools > Internet Options > Advanced > "Disable script debugging (Internet Explorer)" and check "Display a notification about every script error" two lines below to see the error messages.)

Starting the debugger shows the beautifully insightful message “Object required”:

http://skitch.com/troywarr/dui26/ie8-debugging

The culprit is the line:

target = event_object.target || event_object.srcElement;

I think that’s valid code – at least it works in Firefox. My best guess is that there is an issue with trying to access the Event Object of one frame from another – vaguely similar to why you can’t rely on instanceof to detect arrays if they were created in a different window/frame (search for “context” at http://javascript.crockford.com/remedial.html if that didn’t make sense).

Does that sound like a valid theory? If so, what can I do to fix this? If at all possible, I need to preserve the same general code structure/functionality:

  • There is a link inside an <iframe> on a page.
  • A script in the <iframe> calls a function on the parent page, which attaches an event handler to the element in the <iframe> with the specified id attribute.
  • Clicking that <iframe>d link triggers the event, which calls a function on the parent page, passing the Event Object by default.
  • The function on the parent page determines information about the clicked element (the <a>) from the Event Object in a cross-browser-compatible way.

I would also like to continue using event delegation, and keep all of the functions in the parent document, just calling them with arguments from the <iframe>d document. However, if you have any suggestions for alternative approaches, I’d love to hear them.

Thanks in advance for any help! Please let me know if you need any more explanation about my requirements or what I’m trying to do – I’m hoping that there’s just a better way to access or pass the Event Object that I’m not aware of – an “Oh, yeah, you just need to do it like this” kind of solution. I hope that’s not wishful thinking. 😉

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:51:28+00:00Added an answer on May 16, 2026 at 11:51 am

    Easily fixed. You need the event object from the iframe’s window. Store the iframe’s window object next to where you store its document:

    var iframe_win = document.getElementsByTagName('iframe')[0].contentWindow;
    

    … and update the line that gets hold of the event object in your event handler function:

    event_object = event_object || iframe_win.event;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a fairly basic GreaseMonkey script that locates text in a specific
Messing with some javaScript, I found that the variable name item was already being
I found the count down script in http://www.dynamicdrive.com/dynamicindex6/dhtmlcount.htm It works fine if i just
On Chrome I'm getting an error Refused to execute a JavaScript script. Source code
I would like to code an script that would with some trial and error
I am using rhino1_7R2. I have found that the following program causes syntax error(illegally
i am trying to do a form validation using javascript. if error was found
I found javascript is not so easy to master. And I want to dive
In my website I found some javascript codes in js file at the end
I just found Dean Edwards javascript packer here: http://dean.edwards.name/packer/ It has a couple of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.