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

  • Home
  • SEARCH
  • 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 9185899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:23:24+00:00 2026-06-17T19:23:24+00:00

Possible Duplicate: Can javascript access iframe elements from the parent page? I have an

  • 0

Possible Duplicate:
Can javascript access iframe elements from the parent page?

I have an iframe in my document, and I want to get (and change) some attributes in it with JQuery. This is the code:

var iframe = $('iframe');

        $("#id").click(function() {
            var btn = iframe.contents().find('a[href*="script.php"]'); 
            alert(btn);
            for (var i=0, attrs=btn.attributes, l=attrs.length; i<l; i++){
                alert(attrs.item(i).nodeName);
            }
         });

The first alert says “[object Object]”, then I’m getting errors:

Unsafe JavaScript attempt to access frame with URL
http://somedomain.ru/somescript.php from frame with URL
http://domain.wia-games.net/. Domains, protocols and ports must match.

and

Uncaught TypeError: Cannot read property ‘length’ of undefined

How should I solve the problem?

UPD.
console.log(btn):

[prevObject: st.fn.st.init[0], context: document, selector:
“a[href*=”script.php”]”, jquery: “1.9.0”, constructor: function…]
context: #document length: 0 prevObject: st.fn.st.init[0] selector:
“a[href*=”script.php”]”
proto: Object[0]

  • 1 1 Answer
  • 0 Views
  • 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-06-17T19:23:25+00:00Added an answer on June 17, 2026 at 7:23 pm

    This is a constraint implemented on browsers for security reasons: Same origin policy

    Safe Workarounds exist:

    • JSON to JSONP: Bypass Same-Origin Policy
    • Using headers: Content Security Policy 1.1
    • YQL ?!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Data transfer from JavaScript to PHP. How can i get the browser's
Possible Duplicate: Access a JavaScript variable from PHP Let's say I have the following
Possible Duplicate: How can I access local scope dynamically in javascript? Hi all. We
Possible Duplicate: Can Read-Only Properties be Implemented in Pure JavaScript? I have an Object
Possible Duplicate: How can I convert a string to boolean in JavaScript? I have
Possible Duplicate: Prevent any form of page refresh using jQuery/Javascript how can i prevent
Possible Duplicate: How can I obfuscate JavaScript? Hi, I want to compress a JavaScript
Possible Duplicate: How can I get the name of function inside a JavaScript function?
Possible Duplicate: Generate a Hash from string in Javascript/jQuery Can anyone suggest a simple
Possible Duplicate: how can I call javascript function from another project in same solution?

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.