0

It has been many years since I last typed <frameset> into my editor, but today I find myself doing just that.

I'm writing a small tool that makes use of frames. In one frame I have a document with a text input, and in another frame I have a <ul> of items. When I type in the text field in one frame, I need to show/hide items from the <ul> in the other frame. Historically I recall this would work fine. But trying it today, Chrome is throwing a wobbler:

Unsafe JavaScript attempt to access frame with URL file://localhost/Users/chris/multi_yardoc/projects/list.html from frame with URL file://localhost/Users/chris/multi_yardoc/projects/menu.html. Domains, protocols and ports must match.

<script>
  $(document).ready(function() {
    $("#search-box").bind("keyup", function() {
      $("li[class*='object-']", top.frames["list"].document).hide();
      $("li[class*='object-" + $(this).val() + "']", top.frames["list"].document).show();
    });
  });
</script>

The error makes no sense to me, as the domain, protocol and port all match. How do I achieve this?

d11wtq
  • 34,788
  • 19
  • 120
  • 195

1 Answers1

1

Chrome has a special same domain policy for file-protocol urls. See Unsafe JavaScript attempt to access frame in Google Chrome

Community
  • 1
  • 1
  • Bummer, that sucks... this is a "run locally" set of HTML files :( Maybe if I move all the JS into the topmost window that will work. Thanks for point this out! ;) – d11wtq May 19 '12 at 13:35
  • I managed to get something to work by updating the src of the frame to add a hash-bang, then I just watch for changes to `location.hash` in the other frame. It has a weird side-effect of making the browser refresh button flicker, but it works well enough. – d11wtq May 19 '12 at 14:11