Jump to content
Sign in to follow this  
joie

How to add specific script in a single page ?

Recommended Posts

joie

Hi all Is there an option to add a block of javascript to certain page. Because this particular script only relevant to only one page Or is there another wordpress plugin i should use. rgds, joie

Share this post


Link to post
Share on other sites
catrina

Which theme are you using? What is the script for/what does it do? Which page do you want this script to go?


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
joie

the end result when i view source shoul be something like this

	<head>
	<script type="text/javascript">
				function initialize() {
	.
	.
	.
	}
	</script>
	</head>
	<body onload="initialize()">
	.
	.
	
	</body>
	

Share this post


Link to post
Share on other sites
joie

I am using platform pro it is a script from tutorial to add custom google map from this Custom google maps It should be only on my contact page. It is used to display google maps with my custom icons rgds, joie

Share this post


Link to post
Share on other sites
catrina

You can add it to Settings > Custom Code > Headerscripts Even if it's not going to be used on every page on your site, it doesn't hurt to put the script there.


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
joie

how about the <body onload="initialize()"> thing ?

Share this post


Link to post
Share on other sites
joie

i think body is the HTML tag, will the function be called if not specified on the onLoad ?

Share this post


Link to post
Share on other sites
catrina

If it's apart of the HTML and not the script, it should be where the HTML for the custom Google Map.


Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
joie

Got it. I just add window.onload = initialize; before the end of </script> tag so it looks like this

	<head>
	<script type="text/javascript">
	function initialize() { .....}
	window.onload = initialize;
	</script>
	</head>
	<body>.....
	</body>
	

Yeah unfortunately I have not found a plugin to paste the script only specific to my contact page <head> tag thank you Catrina !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×