0

I have a page that have this structure.

<frameset>

    <frame name="MenuFrame"></frame>

    <frameset>
        <frame name="topFrame"></frame>
        <frame name="mainFrame"></frame>
    </frameset>

</frameset>

And in the frame "mainFrame" i need to access some components with javascript.

I can get access to the components when just running the mainFrame in a separate window. Javascript works when running it alone.

When running all the frames i cant do any javascript. What causes this problem?

epascarello
  • 204,599
  • 20
  • 195
  • 236
The Demz
  • 7,066
  • 5
  • 39
  • 43
  • If you can, do not use frame, please, thank you! http://stackoverflow.com/questions/4263509/why-are-frames-deprecated-in-html – Cyril Gandon Aug 03 '11 at 11:05
  • What is the JavaScript code you are using to access the other frame? Seems like that would be good information to share! – epascarello Aug 03 '11 at 11:21
  • Well its not my choice its an very old site that im working on. – The Demz Aug 03 '11 at 11:22
  • @epascarello Im just using `$("#id")` to get the element to see if it is available. – The Demz Aug 03 '11 at 11:30
  • Because frames are DIFFERENT pages and $("#id") lives in a different page. You need to reference the frame where the element lives. – epascarello Aug 03 '11 at 11:57
  • possible duplicate of [Run JQuery in the context of another frame](http://stackoverflow.com/questions/539504/run-jquery-in-the-context-of-another-frame) – epascarello Aug 03 '11 at 11:57
  • Included the `` in all the forms now. I can access the form that I want like this `$('frame').get(2)`. – The Demz Aug 03 '11 at 12:49

2 Answers2

4

For security reasons, the browser won't allow you to script across frames that are served from different domains.

troelskn
  • 115,121
  • 27
  • 131
  • 155
0

But in HTML5 there is a method to archieve this. Google for javascript postMessage() if you want more on this subject. Here's a little example I found: html5demos.com

JanLikar
  • 1,296
  • 9
  • 22