PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Wordpress: jump to highlight

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wordpress: jump to highlight

    Hi,
    Back again, thanks for your previous help.
    Jump to highlight is not working for me.

    I got the highlight.js script from the extras folder and put it in the site's root directory.

    My header.php file includes the style and script lines within the <head> and I added the body on load line immediately below the body class line. Is this correct? :

    <head>

    <?php tha_head_top(); ?>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width">
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <?php tha_head_bottom(); ?>
    <?php wp_head(); ?>

    <style type="text/css">.highlight { background: #FFFF40; }</style>
    <script type="text/javascript" src="/highlight.js"></script>

    </head>

    <body <?php body_class(); ?>>
    <body onload="highlight();">

    thnx!
    phil

  • #2
    No, that'd be two body tags.

    Would probably be more like:

    <body <?php body_class(); ?> onload="highlight();">

    But then that depends on what body_class() does. If it outputs something which breaks the tag or inserts another onload attribute, then it could conflict.

    Also, I presume you've followed the other instructions with enabling jump to highlighting?
    http://www.wrensoft.com/zoom/support/highlighting.html
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

    Comment


    • #3
      Originally posted by Ray View Post
      No, that'd be two body tags.

      Would probably be more like:

      <body <?php body_class(); ?> onload="highlight();">

      But then that depends on what body_class() does. If it outputs something which breaks the tag or inserts another onload attribute, then it could conflict.

      Also, I presume you've followed the other instructions with enabling jump to highlighting?
      http://www.wrensoft.com/zoom/support/highlighting.html
      I cannot say what the body_class() does in my case, I don't know enough php.
      Yes, the support page was where I went first, plus searched for anywhere anyone might be talking about this.
      I even tried adding the strings from the troubleshoot page, though again, that's above my pay grade. : )

      I tried replacing the original body class line with your suggested onload line, above, but could not get it to work.
      Not your job to teach me more php, I know, just wonder how I managed to get this all to work on previous incarnation of the site.

      (on re-reading troubleshoot page, i see examples were for projectseven, so that's why no success, ha)
      thnx

      Comment


      • #4
        body_class() is a WordPress function.

        There's an alternative solution on the troubleshooting jump to highlighting page which does not require changing the <body> tag. Instead, you add a script tag at the end of the page, after the </body> tag.

        Having said that, I honestly can't say if the "jump to highlight" script works for WordPress. There's alot of other JavaScripts in play, and this can vary with version to version, and also if you have different plugins. You said you've got it to work before -- was that using the same version of WordPress and/or plugins?
        --Ray
        Wrensoft Web Software
        Sydney, Australia
        Zoom Search Engine

        Comment


        • #5
          Originally posted by Ray View Post
          body_class() is a WordPress function.

          There's an alternative solution on the troubleshooting jump to highlighting page which does not require changing the <body> tag. Instead, you add a script tag at the end of the page, after the </body> tag.

          Having said that, I honestly can't say if the "jump to highlight" script works for WordPress. There's alot of other JavaScripts in play, and this can vary with version to version, and also if you have different plugins. You said you've got it to work before -- was that using the same version of WordPress and/or plugins?
          Yes, I re-inserted the original body tag in header.php and added the script between the </body> and </html> tags in footer.php (the footer is the only file i know that actually has a </body> tag). No luck, unfortunately.

          This is a new version of WP and it's also a different theme. The previous theme was one I built from scratch in my hack kind of way, but it worked. There are diff plugins this time and I know there can be conflicts.

          I just stumbled into those previous theme files in a windows.old folder from a recent crash. It was the previous version of Zoom. The style and script tags are in the same place in the old header.php. highlight.js is in the old root and I just let all the upload index files go into that root, rather than their own "zoom" folder, like now. Interesting, though, that I had both body tags in the header:

          <body <?php body_class(); ?>>
          <body onload="highlight();">

          Maybe I can duplicate what i did then and see what happens.

          Thanks for your help. If I ever figure it out, I'll update the thread.

          Comment


          • #6
            Hi,

            I did get the plugin to work, highlights on search results page work fine. Jump to Highlight still problematic. It works on certain pages and not on others. It does not work on any page from Home to Recipes (left half of home page menu). It *does* work on every page from Shop, through its sub pages, to Introduction (roughly, the right half of home page menu. Weird. Try the word 'medium'. Doesn't work on first result, but does on #2. Any ideas? : )

            thnx
            http://www.walleyebaits.net
            Last edited by philbu; Jul-15-2015, 01:16 AM.

            Comment


            • #7
              Some quick observations.

              The page where it doesn't work (/walleye-tackle/) contains the following:

              Code:
              <script type="text/javascript">
                          window.onload=function() {
                              lengthObj = document.getElementById('txtLength');
                              girthObj = document.getElementById('txtGirth');
                              weightObj = document.getElementById('tdWeight');
                              document.getElementById('btnReset').onclick = resetInputs;
                              document.getElementById('btnCalc').onclick = calcWeight;
                          }
                          function resetInputs() {
                              lengthObj.value = '';
                              girthObj.value = '';
                              weightObj.innerHTML = '';
                          }
                          function calcWeight() {
                              var length = new Number(lengthObj.value);
                              var girth = new Number(girthObj.value);
                              weightObj.innerHTML = '';
                              if(isNaN(length) || isNaN(girth)) {
                                  alert('Invalid length or girth');
                                  return;
                              }
                              weightObj.innerHTML = length*Math.pow(girth,2)/900;
                          }
                      </script>
              While the page which does work (/walleye-combo/) does not contain the above.

              So I would say it's very likely that script which is clashing with the highlight script. For future reference search for anything else that does an "onload".
              --Ray
              Wrensoft Web Software
              Sydney, Australia
              Zoom Search Engine

              Comment


              • #8
                so, likely in way over my head to make this work.
                but, in a nutshell, in general terms, is there a way around this without dumping that widget?

                Comment


                • #9
                  The code above is overriding the highlight script's execution for onload. In other words, it undoes the <body onload="highlight();"> tag that you've added to the page.

                  To make both work, you'll need to have some familiarity with scripting and what either script does.
                  --Ray
                  Wrensoft Web Software
                  Sydney, Australia
                  Zoom Search Engine

                  Comment


                  • #10
                    ok, thnx. guess i'll check for alternatives, liked the product, wish i could have made it work

                    Comment


                    • #11
                      Originally posted by Ray View Post
                      The code above is overriding the highlight script's execution for onload. In other words, it undoes the <body onload="highlight();"> tag that you've added to the page.

                      To make both work, you'll need to have some familiarity with scripting and what either script does.
                      Hi Ray,

                      I'll admit I'm a hack, but i stumbled on a solution which allows 'jump to highlight' to work on the pages that have the offending widget. saw someone had wrapped a script in this code and i gave it a shot, not sure how it works, but... if you hadn't pointed me in that direction i'd still be lost, so thanks. i have another question i'll pose in a new thread, hopefully easier to resolve.

                      Code:
                      <script type="text/javascript">function soliOnLoad(func){
                                  var boliqOldOnLoad = window.onload;
                                  if (typeof window.onload != 'function') {
                                      window.onload = func
                                  } else {
                                      window.onload = function () {
                                          boliqOldOnLoad();
                                          func()
                                      }
                                  }
                              }
                              soliOnLoad(function(){
                                  window.onload=function() {
                                      lengthObj = document.getElementById('txtLength');
                                      girthObj = document.getElementById('txtGirth');
                                      weightObj = document.getElementById('tdWeight');
                                      document.getElementById('btnReset').onclick = resetInputs;
                                      document.getElementById('btnCalc').onclick = calcWeight;
                                  }
                                  function resetInputs() {
                                      lengthObj.value = '';
                                      girthObj.value = '';
                                      weightObj.innerHTML = '';
                                  }
                                  function calcWeight() {
                                      var length = new Number(lengthObj.value);
                                      var girth = new Number(girthObj.value);
                                      weightObj.innerHTML = '';
                                      if(isNaN(length) || isNaN(girth)) {
                                          alert('Invalid length or girth');
                                          return;
                                      }
                                      weightObj.innerHTML = length*Math.pow(girth,2)/900;
                                  };
                              });
                              </script>

                      Comment

                      Working...
                      X