• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Javascript

Ruroni

Senior member
I have 3 frames One is navigation frame, another frame (called source) where I have a <textarea> and then I have a content frame.

The navigation frame has a function to display source code into textarea in "source.htm".

function displayCode()
{
var sSource = "<html>" + parent.Content.document.getElementsByTagName('HTML')[0].innerHTML + "</html>";
parent.source.sourceCode.value = sSource;
}


which can write the source code of the content frame into the <TEXTAREA> of the left column frame (source). This works wonderfully when loading the Local content, but if the content frame loads an external page, the source code button doesn't work anymore.

So: parent.Content.document.body.outerHTML gets me the source code for Content; the question is how can I make it to where "Content" can be any page I visit? (I tried inserting Google in place of Content, (parent.Google.document.body.outerHTML Since Google is Google's title) and visited content in the display Pane, that didn't work)

I figured maybe somehow getURL (or some kind of function or some trick that could be used across platforms ) into a variable on the navigation? But how to get it form the "Content" frame, into the navigation frame?

Anyone, help?

Thanks in Advances
 
You can't. JavaScript, by design, does not allow cross-domain scripting. Your code can only access the DOM of another page if that page is in the same domain. This is a necessary security measure; without it, you could easily hijack JavaScript on other people's websites.
 
Thanks for the reply, much appreciated.

I'm not sure I understand the explanation; I got the "you can't" aspect of it. (I think I get what you mean when you say cross-domain as in going from google.com to yahoo.com ) But I don't see what's the difference between me displaying the source in a <TEXTAREA> inside a frame (from another frame), and displaying a browser's default view-source in notepad.

I believe there are some sites that don't let you viewi-source, but in those cases, I would imagine they could have the fucntion fail.

I'm not trying to argue, like I got some kind of leg to stand on, cause 1) I obviously don't know a whole lot of nothing and 2) any way I toss it and dice it I can't. But I am trying to understand, and if You can explain or point me in the right direction to develop understanding, I'd appreciate it very much.

Thanks again.
 
Back
Top