You are here:  » Linking External Javascript Documents

Support Forum



Linking External Javascript Documents

Submitted by EIF Media on Wed, 2012-04-25 21:50 in

Hi,

I have been attempting to instert my interactive site logo (as can be seen on my holding page at {link saved}) into the site I'm developing at {link saved} - as I'm pretty new to .php I'm unsure how to do this properly.

Ideally I'd like to link to the javascript document banner2.js externally as with my holding site and simply call the function, but with the added difficulty of this requiring a canvas element I'm really hitting a brick wall.

Any assistance will be appreciated.

Thank you,
Dan

Submitted by support on Thu, 2012-04-26 10:18

Hello Dan,

Could it just be down to the path to the JavaScript; I notice that in your top level test page where the banner shows correctly the header contains:

<script type="text/javascript" src="js/banner2.js"></script>
<script type="text/javascript" src="js/modernizr.custom.41769.js"></script>

...but in /testarea/ this would need to be:

<script type="text/javascript" src="/js/banner2.js"></script>
<script type="text/javascript" src="/js/modernizr.custom.41769.js"></script>

- note the leading "/" infront of js, so that the browser knows where to find the source file. You could add this directly to the area in html/header.php - simply insert it into the line just before closing </head> tag.

With that in place, you should then be able to insert into testarea/index.php the following code:

?>
<canvas id="canvas-banner" class="inactive">
  <img src="images/fallback2.png" />
</canvas>
<script type="text/javascript">
  {code saved}
</script>
<?php

(notice the tags to come out of and then back in to PHP mode as index.php is primarily PHP code)

I've also replaced the bulk of the JavaScript that drives your banner with {code saved} - copy this in from the working version at the top level as required.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by EIF Media on Wed, 2012-05-09 15:25

It did,

I managed to figure it out by having a bit of a play, which I should've done first really.

Thanks again for your support David!

Daniel Crompton
EIF Media / Tapespotter