digitaljoel
digitaljoel

Reputation: 26574

javascript not displaying output when content loaded via jquery

I have a login page that runs a script from a third-party site as so:

<span id="siteseal">
    <script src="https://seal.starfieldtech.com/getSeal?sealID=myspecialid"></script>
</span>

Everything is hunky dory. It performs some javascript and eventually displays an image.

I recently moved it to a separate file, and am including it in the original page using

$('#mydivid').load('/mypath/footer.html');

The entire footer is displayed, and in chrome developer tools I can see that the request is made to starfieldtech and a javascript response is returned, but the image is never displayed.

The getSeal script is pretty simple, looking something like:

<!--
doSomething();

function doSomething() {
    // setup a bunch of vars
    document.write('<img src="blah" onclick="doStuffOnClick();"/>');
}

function doStuffOnClick() {
    // do other stuff on click.
}
// -->

If I create my own script that looks very similar to the above then it replaces the whole page with the output of my script and also shows the intended starfield image.

I have no clue what the problem is and hope the gurus can point out something stupid I'm missing.

Upvotes: 0

Views: 162

Answers (1)

Rob Johnstone
Rob Johnstone

Reputation: 1734

As you can't edit the javascipt returned by starfieldtech.com, I think the only sensible way round this is to use phantom.js (or similar) to pre-process third party html on your server before sending to the browser

Upvotes: 1

Related Questions