• Hello Everyone,

    In the header.php I have link that uses image mapping, it also uses a shortcode via a plug-in to display different content in the different times of the day and the week in that same area. This link opens a “_blank” and let’s the visitor listen to a radio stream. The provider of this radio stream wanted to change the link. Here we go:

    They wanted me to add this to <HEAD>:
    <script language=javascript src="http://nick8.surfernetwork.com/Media/player/scripts/launch.js"> </script>
    … which is of course, simple. And the site runs fine with this in header.php.

    However they wanted me to replace the link with this:
    <a href="javascript:callLTR='SGN';grptuner='';file='';title='';ListenLive();" target="_self"> Listen Live </a >
    … this is part I having trouble with.

    Currently what I have is:

    <?php echo do_shortcode('[timed onday="1" ontime="1500" offtime="1900"]<p class="smallbanner"><img src="http://www.sgnthelight.com/wp-content/uploads/2014/10/listenLive_TBMS.png" width="470" height="56" border="0" usemap="#smallbannermap" />
    <map name="smallbannermap" id="smallbannermap">
      <area shape="rect" coords="2,2,467,54" href="http://lightningstream.surfernetwork.com/Media/player/view/SGN_gsl.asp?StreamingServerName=nick11y&call=SGN&targetWidth=1000&targetHeight=800" target="_blank" />
    </map></p>[/timed]'); ?>

    So, if I put the code in it, it becomes:

    <?php echo do_shortcode('[timed onday="1" ontime="1500" offtime="1900"]<p class="smallbanner"><img src="http://www.sgnthelight.com/wp-content/uploads/2014/10/listenLive_TBMS.png" width="470" height="56" border="0" usemap="#smallbannermap" />
    <map name="smallbannermap" id="smallbannermap">
      <area shape="rect" coords="2,2,467,54" href="javascript:callLTR='SGN';grptuner='';file='';title='';ListenLive();" target="_blank" />
    </map></p>[/timed]'); ?>

    … and once this is implemented the site doesn’t even open, just a blank page comes up.

    Even though I know an imagemap won’t cause it I wanted to try it without that code anyways… so, I’ve reduced the code to work without image mapping… but still doesn’t work, I get the same blank page.

    How can I make this happen? Thank you very much in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter anpu

    (@anpu)

    Can anyone help me with this please?

    Looks like a syntax error. The single quote at the beginning of SGN unintentionally terminates the string to be echoed. You have to use \’ instead of ‘ to indicate a that a particular single quote is not a delimiter. Can’t comment on the logic.

    Thread Starter anpu

    (@anpu)

    Thanks lorro.

    I am not sure if it’s a syntax error; because I’ve tested if there is a syntax error or not by putting the code in that goes in to the <HEAD> then placed the second “link” code in to a post and it does bring up the page I need… it only acts up (as I described what it does before) when the link code is in the header.php. But are you saying if I use \’ instead of ‘ in the second link code it would work?
    Turning this one:
    href="javascript:callLTR='SGN';grptuner='';file='';title='';ListenLive();"
    into this:
    href="javascript:callLTR=\'SGN\';grptuner='';file='';title='';ListenLive();"
    … correct?
    I’ve tried it in the header.php this way; the site still doesn’t come up when it’s in place. What do you think is going on?

    Inside the do_shortcode () brackets, the first and the last ‘ are the delimiters of the overall text string. All the other ‘ inside the text string should be \’ so they are not recognized as the delimiters.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Implementing Javascript in Header.php’ is closed to new replies.