I have a string containing HTML loaded from another page, how do I extract the background property from it’s body tag using Javascript?
The body tag in the string looks like this:
<body onload='init();' background='storage/images/jsb_background.jpg' link='#000000' vlink='#000000' alink='#000000' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
Thanks!
I patched together a regex to do this, which will search the
datastring variable (containing the HTML) for thebackgroundattribute of thebodytag. The regex is stolen from here and modified a bit. I’m still new to regex, so I guess it can be done more fluently, but it still gets the job done