JavaScript OnClick Function

2 posts Page 1 of 1
Contributors
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

JavaScript OnClick Function
mikethedj4
First off to make my question easier for you guys to understand I want you to take a look at my website, and pretend that the about me text isn't there.

Now what I'd like to know is how can I click the navigation for example blog, affiliates, etc: and fill in that about me text with the blog text, but when I click on affiliates, it automatically takes out that blog text, and puts in the affiliates.

I've seen this done plenty of times, but mainly in flash, anywho can anyone help me out here, and explain it as well.

Thanks!

NOTE: That I'd rather not have it pop up in a new window, I'd like to keep it a one page website.
User avatar
rocky4126
VIP - Donator
VIP - Donator
Posts: 258
Joined: Mon Nov 16, 2009 7:39 pm

Re: JavaScript OnClick Function
rocky4126
Code: Select all
<script>
onClick=window.open('url to open','window name','attribute1,attribute2');
</script>
Replace 'url to open' with the web address eg: window.open('google.com');
replace 'window name' with the name of the window (useful for quick referencing) eg window.open('website','google search engine');
and replace the attributes with any of the following:
width=300
Use this to define the width of the new window.

height=200
Use this to define the height of the new window.

resizable=yes or no
Use this to control whether or not you want the user to be able to resize the window.

scrollbars=yes or no
This lets you decide whether or not to have scrollbars on the window.

toolbar=yes or no
Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).

location=yes or no
Whether or not you wish to show the location box with the current url (The place to type http://address).

directories=yes or no
Whether or not the window should show the extra buttons. (what's cool, personal buttons, etc...).

status=yes or no
Whether or not to show the window status bar at the bottom of the window.

menubar=yes or no
Whether or not to show the menus at the top of the window (File, Edit, etc...).

copyhistory=yes or no
Whether or not to copy the old browser window's history list to the new window.

Here is a sample code:
Code: Select all
<script>
onClick window.open('www.google.com','google','width=300,height=200');
</script>
the main bit you want is the URL and don't forget to put: ; at the end of your java command.

Thanks for checking this out!
John
Image
2 posts Page 1 of 1
Return to “Help & Support”