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 11-19-2003, 07:21 PM   PM User | #1
Norm White
New to the CF scene

 
Join Date: Nov 2003
Location: Virginia
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Norm White is an unknown quantity at this point
Using DOM to get at the contents of a modified frame

The application that I am trying to develop is a web-crawler written in JavaScript. The top module called JSBrowse.html defines two frames: an upper one called toppart, and a lower one called bottompart. Toppart.html in turn defines two frames: one called leftpart and one called rightpart. (I would have atached all 4 modules, but I don't know how to attach more than one module, so I chose rightpart.html.)

Leftpart shows the current www page that you have crawled to.

Rightpart contains a button that takes you to the next page in what will eventually be a pushdown list.

Bottompart scans each page for the presence of keyword, and also shows the dom structure of the document.

In rightpart I use this statement to update the URL of leftpart: parent.frames('leftpart').window.document.URL=document.form1.text1.value;

THE PROBLEM IS: The DOM tree that is displayed is the tree of my original html page (i.e., leftpart). What I want is the DOM tree of the current content.

I own 5 books on JavaScript including "HTML Black Book", "JavaScript: The Complete Reference", and 3 others, and I have not found the answer to my question.

I could sure use a clue, or ideas to solve this problem.

Thanks,
Sincerely
Norm White is offline   Reply With Quote
Old 11-19-2003, 07:26 PM   PM User | #2
adios
Senior Coder

 
Join Date: Jun 2002
Posts: 1,404
Thanks: 2
Thanked 32 Times in 32 Posts
adios is on a distinguished road
Not really enough to go on - but this is nasty:

parent.frames('leftpart').window.document.URL=document.form1.text1.value;

You're using parentheses as array element operators - OK in IE (VBScript convention) but nowhere else. document.URL is read-only. Try:

top.frames.leftpart.location=document.form1.text1.value;
adios is offline   Reply With Quote
Old 11-19-2003, 08:06 PM   PM User | #3
Norm White
New to the CF scene

 
Join Date: Nov 2003
Location: Virginia
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Norm White is an unknown quantity at this point
I changed the statement to:
parent.frames.leftpart.location= . . .
It also works, but no differently from what I orignally had.
When I click the button, an error message comes up on that statement (either on the old or the new) which says "permission denied". However, if I click the back button and then click my "Next Page" button it fetches the next page in OK.

The more serious problem is getting the DOM structure of the replacement page. My DOM parsing code is:
<!--***********************Move HTML text into the bottompart frame-->
top.frames('bottompart').form2.analyze.value="";
var i,imax=40,k=0,origLength,delta="";
var currentElement = parent.frames('leftpart').window.document.documentElement;

i=imax;
origLength=parent.frames('leftpart').window.document.all.length;

<!--for (i=0;i<origLength;i++)-->
while (i-- > 0)
{
if (i==imax-1)
{
top.frames('bottompart').form2.analyze.value=currentElement.outerHTML+"\n";
}
top.frames('bottompart').form2.analyze.value=
top.frames('bottompart').form2.analyze.value+delta+
currentElement.nodeName+" "+
"nodeType="+currentElement.nodeType+" "+
"nodeValue="+currentElement.nodeValue+"\n";

if (k==0 && currentElement.hasChildNodes())
{
currentElement=currentElement.firstChild;
delta=delta+" ";
}
else
if (currentElement.nextSibling)
{
k=0;
currentElement=currentElement.nextSibling;
}
else
if (currentElement.parentNode)
{
currentElement=currentElement.parentNode;
delta=delta.substring(0,delta.length-5);
k=1;
}
else
break;
}
Norm White is offline   Reply With Quote
Old 11-19-2003, 10:33 PM   PM User | #4
COBOLdinosaur
Regular Coder

 
COBOLdinosaur's Avatar
 
Join Date: Jul 2002
Location: Canada
Posts: 293
Thanks: 0
Thanked 18 Times in 18 Posts
COBOLdinosaur is an unknown quantity at this point
You are trying to script cross-domain. That is a security violation. If you could modify code cross-domain, it would be a huge security hole.

Cd&
__________________
100% standards compliant code is 100% correct 100% of the time.
one of my toys from my repository and perhaps some help getting help

Cd&
COBOLdinosaur 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 06:42 AM.


Advertisement
Log in to turn off these ads.