Accessing Webgadget Content

Just starting out? Need help? Post your questions and find answers here.
jamirokwai
Posts: 40
Joined: Fri Sep 25, 2015 12:00 pm

Accessing Webgadget Content

Post by jamirokwai »

Hi there,

just fiddling around with the demo of SpiderBasic :-)

By calling gad = GadgetID(webgad); and issuing ! alert ( v_gad ); , Safari tells me the HTML.
That's ok. Now I need to access a div called mydiv, and call JavaScript-function named myfunc().
Didn't work with jquery before, maybe that does the trick?

Any ideas?

Thanks
J.
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Accessing Webgadget Content

Post by Fred »

Hum, I don't know if you can trigger a function in a frame by code.
jamirokwai
Posts: 40
Joined: Fri Sep 25, 2015 12:00 pm

Re: Accessing Webgadget Content

Post by jamirokwai »

YESS!

Code: Select all

WebGadget    (0, 10, 50, 960, 600, "test.html")
gadid = GadgetID(0)
This one will output the complete HTML to the browser console

Code: Select all

!console.log(v_gadid.gadget.contentDocument);
This one will call the function show(), which I declared in the head section (should work everywhere, as long as the window finished loading)

Code: Select all

!v_gadid.gadget.contentWindow.show();
And this will alert the content of the variable 'declaration'

Code: Select all

!alert(v_gadid.gadget.contentWindow.declaration);
Works in Safari 9.0.1, FireFox , Chrome 45.0.2454.101 (64-bit)

Duplicate in Tips & Tricks here: http://forums.spiderbasic.com/viewtopic.php?f=9&t=420
Last edited by jamirokwai on Thu Oct 01, 2015 4:06 pm, edited 1 time in total.
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Accessing Webgadget Content

Post by Fred »

looks great !
Post Reply