Jump to content

Finding strings on HTML doesn't work.


pureskill

Recommended Posts

var max = 2;var hatId = 32199211; function test(){var ifr = document.createElement('iframe');document.body.appendChild(ifr);ifr.id = "ok";var exp = document.getElementById('ok');exp = exp.contentWindow.document || exp.contentDocument;var p = exp.getElementsByTagName("pre");          for (var v=1; v<max; v++)          {          var url = "http://api.roblox.com/ownership/hasasset?assetId=" + hatId + "&userId=" + v + "";          ifr.src = url;        console.log(ifr.src);        for(var z=0; z<p.length; z++){          if (p[z].innerHTML == "true") {          console.log(v);          console.log("true");        }       }}} var timer = setInterval("test()", 200);

it won't stop logging, also i can't get it to log the url + value

 

  1. Uncaught TypeError: Cannot call method 'getElementsByTagName' of null

2
  1. Blocked a frame with origin "chrome://newtab" from accessing a frame with origin "http://api.roblox.com". The frame requesting access has a protocol of "chrome", the frame being accessed has a protocol of "http". Protocols must match.

  1. Uncaught TypeError: Cannot call method 'getElementsByTagName' of null

2
  1. Blocked a frame with origin "chrome://newtab" from accessing a frame with origin "http://api.roblox.com". The frame requesting access has a protocol of "chrome", the frame being accessed has a protocol of "http". Protocols must match.

  1. Uncaught TypeError: Cannot call method 'getElementsByTagName' of null

Edited by pureskill
Link to comment
Share on other sites

Uh, I'm not really familiar with iframe stuff but isn't it a little odd to be extracting a list of elements by tag name before you've even assigned a url to the iframe? I don't think that will work.Then the url ends with a little null string? Also you loop from v=1 to v=1?

 

Also when I browse to http://api.roblox.com/ownership/hasasset?assetId=32199211&userId=1

 

I am served the text 'true' and it isn't wrapped in a pre tag. You can't specify getElementsByTagName('pre') if the text nodes are not wrapped in pre tags. In the unwrapped case you would use getElementsByTagName('*').

 

Also from http://www.w3schools.com/jsref/prop_frame_contentdocument.asp

 

"Note: Because of security reasons, the contents of a document can be accessed from another document only if the two documents are located in the same domain." So you have to be displaying local pages in the iframe.

 

Also why do you dynamically create the iframe? Are you planning to fill the page with a column of iframes?

 

Also this code needs to be broken into a loop and an event handler. You are changing the src of the iframe and then exploring the iframe document so each time you need to wait for the iframe to load with an onload event handler.

Edited by davej
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...