Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to Add a Script to a Specific Page
- This topic has 14 replies, 2 voices, and was last updated 12 years, 3 months ago by
futurewebboss.
-
AuthorPosts
-
October 1, 2013 at 7:46 pm #65030
futurewebboss
MemberThis is a bit of an advanced topic but I'm hoping someone can help me out. I am creating a video sales letter that I want to put on a site that is using the Lifestyle theme. I plan on using the landing page template. Now what makes this unique is that the page will have a video sales letter that I want to support with a unique script that will reveal the buy button after a given number of seconds have passed. I am sure that many of you have experienced these. The video plays and then at a specific point in the video, presto chango, the buy button magically appears. The java script should go in the head section. Now I know that Genesis Simple hooks might be integral in this but would have to identify a specific page so that the script only executes given the specific page. The other option would be to create a new page template (I guess) and then hard code the java script into the new page template. Am open to anyone who has any suggestions or who can donate any code on this.
Thanks in advance,Dan
October 1, 2013 at 8:06 pm #65034Brad Dalton
ParticipantThere's a script box on every page.
Or you can conditionally load it.
Sample code:
https://gist.github.com/braddalton/5943226
October 1, 2013 at 8:48 pm #65040futurewebboss
MemberWow! Thanks for the quick response.
This code would go in the head portion of genesis simple hooks?October 1, 2013 at 10:16 pm #65047Brad Dalton
ParticipantAt the end of your child themes functions.php file.
You will need to modify it slightly to suit your own needs.
October 2, 2013 at 4:14 pm #65122futurewebboss
MemberThis reply has been marked as private.October 2, 2013 at 6:54 pm #65153Brad Dalton
ParticipantSorry but i cannot receive private messages.
You can contact me using the form on my site http://wpsites.net/contact/
October 2, 2013 at 7:13 pm #65158futurewebboss
MemberBrad,
Not sure I understand exactly what to do here and where to exactly place the script I have. In the example you provide there are two places where it says “your script”. Does this mean I have to put my script in both places? Sorry to be such a pain but want to get this right and do appreciate your time.
Dan
FYI here is my script.
———–Script In The Header———<script type=”text/javascript”>
//hidden buy button
function showIt() {
document.getElementById(“hid”).style.display = “block”;
document.getElementById(“lf”).style.display = “block”;
}
setTimeout(“showIt()”, 300000); // Time in Seconds x 1000
</script>—————————————-
———–On the Page —————–
<div align=”center” id=”hid” style=”display:none;”>
Hidden Content Goes Here
</div>
—————————————-
October 2, 2013 at 8:05 pm #65162Brad Dalton
ParticipantYou need to paste the script into a file in a js folder in your child theme unless its hosted already.
Then add the script name to the code.
Otherwise use the scripts box under all edit screens.
October 2, 2013 at 8:37 pm #65163futurewebboss
MemberGoing way beyond my knowledge at this point.
October 3, 2013 at 9:32 am #65206futurewebboss
MemberBrad,
Question.......
1. Paste the script in a file is pretty straight forward, but what would the file extension be?October 3, 2013 at 2:12 pm #65248Brad Dalton
ParticipantIf you save it as a .js file then it will be js as indicated in the code.
/js/your-script.js
and you can create a new folder and name it js as well.
The name will be your-script
Any reason you don't want to use the scripts box?
October 3, 2013 at 3:41 pm #65259futurewebboss
MemberActually, now that you mention it I hadn't thought of looking for it. So we're saying that the scripts box can take this same code when I create a new page? This is obviously the best but hadn't even noticed it. I will test it.
October 10, 2013 at 2:37 pm #66177futurewebboss
MemberWell the script in the script box did not work. Any ideas as to maybe why?
October 10, 2013 at 3:00 pm #66178futurewebboss
MemberActually, it kind of does work but it displays the hidden content not below the video but at the top of the page. Hm?
October 10, 2013 at 3:12 pm #66180futurewebboss
MemberHorray!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Got it working.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.