Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-08-2006, 04:20 PM   PM User | #1
gjenkins
New to the CF scene

 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
gjenkins is an unknown quantity at this point
Iframe getElementsByTagName() Works on Local File but not External

I am new to DOM scripting, and I can not find documentation on this ... The following script never completes the getElementsByTagName("A") call if the "content" frame is loaded with a live site like www.google.com or www.dictionary.com, etc ... IF I take the same sites, and copy the source to a local file and then use that file in the frame, then the call works fine.

===== Page Follows =====>

<html><head><script type="text/javascript">

function filter()
{
var output = document.getElementById("output").contentDocument;
if( output ) { output.write( "output found<BR>\n" ); }

var content = document.getElementById("content").contentDocument;
if( content ) { output.write( "content found<BR>\n" ); }

var obj = content.getElementsByTagName("A");

output.write( "Tags Found!<BR>" );

for( var i=0;i<obj.length;i++)
{
output.write( "_<BR>" );
}

output.write( "Tags Iterated!<BR>" );
return 0;
}

</script></head><body>

<a onclick="filter();">filter</a>

<div id="out">
<iframe name="output" id="output" frameborder="2" height=100 width=100% scrolling=auto>
</iframe>
</div>

<div id="cntnt">
<iframe name="content" id="content" frameborder="0" src="http://www.google.com/" height=100% width=100% scrolling=auto>
</iframe>
</div>

</body></html>
gjenkins is offline   Reply With Quote
Old 02-08-2006, 05:15 PM   PM User | #2
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
It's the security model of JavaScript that does that - it only gives access to documents originating from the same domain. This is called the Same Origin Policy.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 02-08-2006, 05:23 PM   PM User | #3
gjenkins
New to the CF scene

 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
gjenkins is an unknown quantity at this point
I see, and thank you! Ultimately, I can get the script inlined into pages on the site I am concerned with, but I have a couple o questions ...

1. Can it be subverted? In this case to implement a generic filter on external pages.

2. If I host a script on a remote server, but include it in files on the server in question, will that work?
gjenkins is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:24 AM.


Advertisement
Log in to turn off these ads.