473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Walking the tree node on a page from another domain

Claus Mygind
571 512MB
I have been working with the TreeWalker. I want to load a page from another domain. I got that working fine. I store window.open() object in a global variable winRef.

Then I would like to walk the nodes and find an anchor that contains "seek/log" in it's href attribute.

Can that be done or is that a security violation and not permitted?

I load the winRef variable like this
Expand|Select|Wrap|Line Numbers
  1.  
  2. winRef = window.open("http://www.otherSite.com" );
  3.  
I have tried both of the following:
Expand|Select|Wrap|Line Numbers
  1.     var rootnode=winRef.document.getElementById("Form1")
  2.     var walker=winRef.document.createTreeWalker(rootnode, NodeFilter.SHOW_ELEMENT, myfilter, false)
  3.  
and
Expand|Select|Wrap|Line Numbers
  1.     var rootnode=winRef.getElementById("Form1")
  2.     var walker=winRef.createTreeWalker(rootnode, NodeFilter.SHOW_ELEMENT, myfilter, false)
  3.  
each time I get the error "Permission denied".


below is my tree walker code.


Expand|Select|Wrap|Line Numbers
  1.  function walkTheNodes()
  2.  {
  3.     //var rootnode=document.getElementById("Form1")
  4.     var rootnode=winRef.getElementById("Form1")
  5.     var walker=document.createTreeWalker(rootnode, NodeFilter.SHOW_ELEMENT, myfilter, false)
  6.  
  7.  
  8.     //Step through and alert all child nodes
  9.     while (walker.nextNode())
  10.     alert(walker.currentNode.tagName) 
  11.  
  12.     var cHref = walker.currentNode;
  13.     var cChk  = walker.currentNode.href;
  14.  
  15.     var i = walker.currentNode.href.indexOf("seek/log");
  16.  
  17.     if ( i != -1 )
  18.     {
  19.         alert(walker.currentNode.href);
  20.     }else{
  21.         alert("Did not find");
  22.     }
  23.  
  24.     //Go back to the first child node of the collection and alert it
  25.     walker.currentNode=rootnode //reset TreeWalker pointer to point to root node
  26. }
  27.  
  28. myfilter=function(node){
  29. if ( node.tagName=="A") //filter out INPUT
  30. return NodeFilter.FILTER_ACCEPT
  31. else
  32. return NodeFilter.FILTER_SKIP
  33. }
  34.  
Oct 31 '09 #1
4 1811
acoder
16,027 Expert Mod 8TB
Yes, this is not going to be possible, but you can serve the page from your domain to avoid cross-domain problems.
Nov 1 '09 #2
Claus Mygind
571 512MB
Ok so how do I capture the page from the domain that is not mine and re-load it from my domain as you suggest?
Nov 8 '09 #3
acoder
16,027 Expert Mod 8TB
See this link for some ideas. Although it is geared towards Ajax, the article is still relevant.
Nov 8 '09 #4
Claus Mygind
571 512MB
Thank you very much for the link. I have also read up on the proxy server idea. I will play around with that and post any success story if I have one. Opening up a proxy may be more of a security problem than I want to deal with to save one click on the mouse. But at least I can see how it is done.
Nov 9 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: t_pet422 | last post by:
Hi, I've been scouring the net and reading the PostgreSQL docs for a while now trying to learn how to create a recursive function in PL/pgSQL that will return a whole subtree given a starting...
12
by: pillepop2003 | last post by:
Hey! Can anyone give me a hint, how this problem is best implemented: I have a table of users (see below), where every user has one "superior user" (= parent node), this should be a fully...
4
by: Robin Tucker | last post by:
Hi, I'm currently implementing a database with a tree structure in a table. The nodes in the tree are stored as records with a column called "Parent". The root of the tree has a "NULL" parent....
0
by: Tree menu using XML | last post by:
I have one XML file that has nodes and sub node and each and every node has the attribute call visible if its value is true then diplay this node else don't display thid node, but this condition i...
19
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has...
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
5
by: pembed2003 | last post by:
Hi, I have a question about how to walk a binary tree. Suppose that I have this binary tree: 8 / \ 5 16 / \ / \ 3 7 9 22 / \ / \ / \
15
by: Foodbank | last post by:
Hi all, I'm trying to do a binary search and collect some stats from a text file in order to compare the processing times of this program (binary searching) versus an old program using linked...
1
by: Amit Bhatia | last post by:
User-Agent: OSXnews 2.081 Xref: number1.nntp.dca.giganews.com comp.lang.c++:817435 Hi, I searched online to see if this is valid or not (since my classes are still very incomplete, I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.