We help IT Professionals succeed at work.
Get Started

Exception reading an iframe content from chrome console

Last Modified: 2016-03-21
I have a following html page  :
<!DOCTYPE html>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">

    <script>var mode = "${mode}"</script>
    <script>var require = {config: function (c) {require = c}}</script>
    <script src="${resourcePrefix}/js/config.js"></script>
    <script data-main="${resourcePrefix}/js/view.js" src="${resourcePrefix}/lib/require.js"></script>
    <link media="screen and (min-device-width: 737px)" rel="stylesheet" href="${resourcePrefix}/css/view.css"/>
    <link media="only screen and (min-device-width: 320px) and (max-device-width: 736px)" rel="stylesheet" href="${resourcePrefix}/css/view-mobile.css" />

    <h1 id="title">${note.title}</h1>
    <div id="textContainer">
    <iframe id="iframe" scrolling="yes" frameborder="0" style="position: relative; height: 100%; width: 100%;" src="${dataUri}">
    <div id="buttons">
        <button id="edit">Edit Note</button>
    <div class="invisible" data-edit-url="${editURL}">

Open in new window

This page is a jsp which is returned from server running at my local machine.
However if i type the following command in console : $('iframe').contents() i get the following error :
Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://localhost:8080" from accessing a cross-origin frame.(…)n.each.contents @ jquery-2.1.4.min.js:2n.extend.map @ jquery-2.1.4.min.js:2n.fn.(anonymous function) @ jquery-2.1.4.min.js:2(anonymous function) @ VM449:2InjectedScript._evaluateOn @ VM302:875InjectedScript._evaluateAndWrap @ VM302:808InjectedScript.evaluate @ VM302:664

Which is strange as the iframe is loaded from my local server its not loaded from some other domain...
Also the same thing works fine on firefox.. Its only causing problems in chrome .

How can i get rid of this ?
Watch Question
Fixer of Problems
Most Valuable Expert 2014
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE