I’ve painted myself into a corner, and I can’t use any server-side solutions.
With some help, I’ve been working on a script on x.html that searches for a specific “image Y” within “Y.html” (inside an iframe). Then the script replaces the “Image x” url to the url of “image Y”.
It drills through a specific div, to a specific span, to find this image Y. I have it this way, because it’s a pre-built content management system that hasn’t given me the ability to show the image on another page. I need to do this several times on one html file, so I’m running into huge load times, and there seem to be numerous clashes with servers and locking up. So I’m hoping there’s a way to just avoid iframes and achieve the same result.
Here’s the script that I’ve got, to help understand what I’ve done. Any suggestions on how to access the info on a different html – without iframes.
[CODE]
<iframe id=IFrame1 width=’5′ height=’5′ frameheight=’5′ framewidth=’5′ frameborder=’5′ src=”http://frontdoorsnews.com/cover_stories/?page=complete” ></iframe>
<script type=”text/javascript” language=”JavaScript”>
function find_div_class() {
var iframe = document.getElementById(‘IFrame1’);
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var info = innerDoc.getElementsByClassName(“list-journal-entry-wrapper”)[0];
var theURL = null; // assume not found
var spans = info.getElementsByTagName(“span”);
for ( var s = 0; s < spans.length; ++s )
{
// have to search through spans for the class name:
var span = spans[s];
if ( span.className.indexOf(“full-image-float-left”) >= 0
&& span.className.indexOf(“ssNonEditable”) >= 0 )
{
// we found the right one
// get FIRST image inside that span:
var image = span.getElementsByTagName(“img”)[0];
// and then the image link:
theURL = image.src;
break; // quit when we find first one
}
}
if ( theURL == null )
{
alert(“I can’t find the darned thing!”);
} else {
var img = document.getElementById(‘lead1’);
img.src = (theURL);
return false;
}
}
</script>
<img src=”/storage/images/placeholder_mug.gif?__SQUARESPACE_CACHEVERSION=1314645589635″ id=”lead1″ alt=”” onload=”find_div_class()”/>