How to insert SpiderBasic code into an exhisting html file?

Just starting out? Need help? Post your questions and find answers here.
Alberto
Posts: 3
Joined: Thu Jul 28, 2016 1:28 pm

How to insert SpiderBasic code into an exhisting html file?

Post by Alberto »

I' m a very happy user of PureBasic and I want to know if is it possible to insert SpiderBasic code into an exhisting html file made by another program (Dreamweaver for example). I imagine two ways of inserting the SpiderBasic code:

1) There is a rectagle area in the html page that it's a SpiderBasic Window

2) The background of the html page it's a SpiderBasic Window with #PB_Window_Background flag.

I failed in both of these two way.
When I try to mix html elements and spiderbasic elements on the same page the browser first shows the html elements then redraw the page and shows only the spiderbasic elements. I tried to move the <div class="flat" id="spiderbody"> in a different position (inside the <body> tag for example) but I had no success.

I haven't found an example with this integration. All the included examples only contains html elements that are totally made by SpiderBasic.

Any suggestion?

Thanks in advance
Alberto
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: How to insert SpiderBasic code into an exhisting html fi

Post by SparrowhawkMMU »

You might be able to use an <iframe>

for example:

Code: Select all

 <iframe id="myiframe" src="http://my-spiderbasicsite.com"></iframe> 
You can then use the contentDocument peoprerty of the iframe to manipulate it via the DOM, eg (Javascript from parent doc)

Code: Select all

var myframe = document.getElementById("myiframe");
var mydoc   = (myframe.contentWindow || myframe.contentDocument);
if (mydoc.document) {
    mydoc = mydoc.document;
}
mydoc.body.style.backgroundColor = "powderblue";
PS - not tested, but in principle this should work. It's adapted fomr a W3C example so should be OK
Alberto
Posts: 3
Joined: Thu Jul 28, 2016 1:28 pm

Re: How to insert SpiderBasic code into an exhisting html fi

Post by Alberto »

Thank you SparrowhawkMMU.

I've tested it and works good.
This is what I was looking for.

Thanks again
Alberto
Post Reply