Using Javascript from SpiderBasic
kwandjeen
 
Posts: 6
Joined: Thu Oct 27, 2016 8:02 pm

iframe content

by kwandjeen Thu Nov 15, 2018 9:43 am

How read a iframe content ?
Code: Select all
define elements
define iframe_content
define length_elements

!var v_elements = document.querySelectorAll("iframe");
!var v_length_elements = elements.length;
!var v_iframe_content = v_elements[0].innerHTML;

debug elements
debug length_elements
debug iframe_content


elements is a node object
length_elements is ok
iframe_content is empty
If anyone has a solution :)
User avatar
Peter
 
Posts: 553
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: iframe content

by Peter Thu Nov 15, 2018 9:49 am

kwandjeen wrote:iframe_content is empty

This is because the page may not yet be completely loaded?

Greetings ... Peter
kwandjeen
 
Posts: 6
Joined: Thu Oct 27, 2016 8:02 pm

Re: iframe content

by kwandjeen Thu Nov 15, 2018 10:33 am

if i call a function with
Code: Select all
window.onloadend
I have the same result
User avatar
Peter
 
Posts: 553
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: iframe content

by Peter Thu Nov 15, 2018 10:59 am

kwandjeen wrote:if i call a function with
Code: Select all
window.onloadend
I have the same result

without knowing your code: if the page in your iframe does not come from the same domain as your app, you cannot access its content.

https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
kwandjeen
 
Posts: 6
Joined: Thu Oct 27, 2016 8:02 pm

Re: iframe content

by kwandjeen Thu Nov 15, 2018 11:18 am

Ok that's it :(

I load a web page in webgadget and spiderBasic use the iframe.

In google chrome I read the div tags by injection of javascript in console. Can we do the same thing with spiderBasic ?
exemple
Code: Select all
var elements = document.querySelectorAll("div");
for (let element of elements){
    console.log(element.title);
}
User avatar
Peter
 
Posts: 553
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: iframe content

by Peter Thu Nov 15, 2018 12:25 pm

kwandjeen wrote:In google chrome I read the div tags by injection of javascript in console. Can we do the same thing with spiderBasic ?

Unfortunately, I don't understand your question. Can you describe that in more detail?
kwandjeen
 
Posts: 6
Joined: Thu Oct 27, 2016 8:02 pm

Re: iframe content

by kwandjeen Sun Nov 18, 2018 5:11 pm

Load a web page with google chrome browser.
In console of developer tools i write the line
Code: Select all
var elements = document.querySelectorAll("div");
for (let element of elements){
    console.log(element.title);
}


And in the console i can read the list of div tags title.
Return to Javascript

Who is online

Users browsing this forum: No registered users and 1 guest