[Resolved] Adding Javascript to header

Home Forums Support Adding Javascript to header

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #114733
    MICHAEL HOLLAND

    Hi Tom
    I’m trying to add a button to the header of my website. The pop-up button has a javascript snippet behind it. I’ve tried different wordpress plugins that allow javascript to be added to a custom widget, but nothing seems to be working. I’m not a techie, so I’m looking for an easy solution. Any ideas? Here’s the code snippet.

    <script src=”http://code.jquery.com/jquery-1.11.0.min.js”></script&gt;
    <script src=”http://salestextchat.com/chat/ptest.php&#8221; type=”text/javascript”></script>

    #114747
    Tom
    Lead Developer
    Lead Developer

    Hi Michael,

    No need for this line, WordPress has jQuery enqueued by default:

    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

    Other than that, you should be able to add that code into a regular Text widget, which supports HTML and javascript. If the JS is correct, it should work.

    Let me know 🙂

    #114754
    MICHAEL HOLLAND

    Hi Tom…

    So I installed a plugin called “Extended Text” which is touted to accept javascript. I then added one of the extended text widgets to the header. I removed the first line of code from the snippet. What happened is that all of the content on the site disappeared from view. By the way, I just noticed that not all of the javascript showed up in my prior post, so trying again below.

    `
    /////
    <script src=”http://salestextchat.com/chat/ptest.php&#8221; type=”text/javascript”></script>/////

    Edited: Still looks like not all the javascript is showing up in this posting.

    #114757
    MICHAEL HOLLAND

    Here’s a link to view an image of the entire javascript
    Javascript snippet

    #114762
    Tom
    Lead Developer
    Lead Developer

    You can post code in here as long as you highlight it and click the “code” button in the editor 🙂

    You shouldn’t need any special plugins to add JS to widgets – the text widget should accept it just fine.

    Is it possible to see the site? I’m curious to see if there’s any JS errors going on.

    #114765
    MICHAEL HOLLAND

    Sure Tom…go to Imaginequest Marketing

    And let me know if you need me to do anything or direct access to the site. The code something standard being used by a lot of people. Also, I tried the standard text widget and got the same error.

    Thanks
    Michael

    #114777
    Tom
    Lead Developer
    Lead Developer

    Is the code supposed to be in the header widget? I’m not seeing it?

    #114795
    MICHAEL HOLLAND

    Hi Tom…

    Sorry, I just added it.

    #114856
    Tom
    Lead Developer
    Lead Developer

    Is the JS supposed to display something? I’m only seeing the phone number and some text in the header.

    #114861
    MICHAEL HOLLAND

    Hi Tom…

    Yeah, it’s supposed to display a button that says Text Us … very similar to what you see in the header of this site…http://demo.carsalesspecialist.com/

    Once you click on the button, a form is suppose to pop up.

    Michael

    #115001
    MICHAEL HOLLAND

    `Hi Tom

    Just curious, do you have a sandbox site where you test things? I’m curious as to whether the code worked on that site. By the way, the reason that you only see text in the header of my site is because the javascript is causing the rest of the site to disappear from view. Yes, there’s actually a real site somewhere in there…lol The text that you see resides in the same box as the script.

    Michael

    #115064
    Tom
    Lead Developer
    Lead Developer

    This code worked for me:

    <script src="http://salestextchat.com/chat/ptest.php" type="text/javascript"></script>
    <img onclick="dTwClickScript(this, '?widgets=572&affid=')" style="cursor:pointer;" alt="" src="http://salestextchat.com/chat/chat_images/1.png" />

    However, I did get a JS error which is on their part.

    They need to specify jQuery in their function, instead of just using “$”.

    That’s something the people hosting the script will have to adjust unfortunately.

    #115069
    MICHAEL HOLLAND

    Thanks Tom…so you got it to work in the text header widget huh? I’ve disabled all plugins except for the GP Premium and the problem persists. Very strange and frustrating. Ah well, if any other ideas pop into your mind as to what I might try, please let me know. But I certainly appreciate you taking a look.

    Cheers
    Michael

    #115095
    Tom
    Lead Developer
    Lead Developer

    I did – I placed the code I pasted above into my dev header widget – the button showed up, and I was able to click it, but I did notice the error I mentioned above.

    I placed it inside the regular Text widget. I’m not sure what would be causing your site to disappear when trying to add the code – JS won’t typically do that (PHP will!).

    Are you just trying to display some content inside a popup?

    #115155
    MICHAEL HOLLAND

    Hi Tom…

    The pop up is a form where content can be entered to initiate and carry on a mobile texting conversation.

    It’s so weird to me that I deactivated all plugins and yet don’t get anything close to the result you got. Any ideas as to what my next course of action should be?

    Thanks
    Michael

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.