- This topic has 18 replies, 2 voices, and was last updated 8 years, 3 months ago by
Tom.
-
AuthorPosts
-
June 15, 2015 at 9:46 am #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>
<script src=”http://salestextchat.com/chat/ptest.php” type=”text/javascript”></script>
June 15, 2015 at 10:33 am #114747Tom
Lead DeveloperLead DeveloperHi 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 ๐
June 15, 2015 at 11:00 am #114754MICHAEL 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” type=”text/javascript”></script>/////
Edited: Still looks like not all the javascript is showing up in this posting.
June 15, 2015 at 11:10 am #114757MICHAEL HOLLAND
Here’s a link to view an image of the entire javascript
Javascript snippetJune 15, 2015 at 11:28 am #114762Tom
Lead DeveloperLead DeveloperYou 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.
June 15, 2015 at 11:34 am #114765MICHAEL 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
MichaelJune 15, 2015 at 11:35 am #114777Tom
Lead DeveloperLead DeveloperIs the code supposed to be in the header widget? I’m not seeing it?
June 15, 2015 at 12:19 pm #114795MICHAEL HOLLAND
Hi Tom…
Sorry, I just added it.
June 16, 2015 at 12:02 am #114856Tom
Lead DeveloperLead DeveloperIs the JS supposed to display something? I’m only seeing the phone number and some text in the header.
June 16, 2015 at 12:24 am #114861MICHAEL 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
June 16, 2015 at 1:17 pm #115001MICHAEL 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
June 16, 2015 at 8:32 pm #115064Tom
Lead DeveloperLead DeveloperThis 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.
June 16, 2015 at 9:10 pm #115069MICHAEL 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
MichaelJune 17, 2015 at 12:19 am #115095Tom
Lead DeveloperLead DeveloperI 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?
June 17, 2015 at 8:03 am #115155MICHAEL 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 -
AuthorPosts
- You must be logged in to reply to this topic.