FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

JAVASCRIPT FUNCTION- ONCLICK HELP!!

 


since83
So Here is my dilemma: on my site http://www.since83.net, I am trying to make the div that contains my left side navigation (mainNav) to "onClick" with java and load a "blank.html" into another div that has an iframe (imageFrame) inside of it. Ideally what I am looking to do is when you click on "Info" then my "subNav" appears and then let's say you click on "Contact". Now I have 2 iframes (subNavFrame + imageFrame) inside two differently named divs (subNav + imageStage). Then when a user clicks on "Design" I would like the "subNav" to display the list of projects and the ImageFrame to link to a blank.html (which is just to clear the div/iframe).

I currently have the functions in my index page as :

<script language="javascript">
function blankImageStage()\{\
document.getElementById('imageFrame').src='blank.html';
}</script>

and under my main navigation like so :
<div onClick="javascript:blankImageStage()" id="mainNav">

but nothing seems to happen ?
Any help or suggestions? I thank you ahead of time. I am just starting out using HTLM and javascript.
Hoping to learn more!

- Ty
halilibo
since83 wrote:
So Here is my dilemma: on my site http://www.since83.net, I am trying to make the div that contains my left side navigation (mainNav) to "onClick" with java and load a "blank.html" into another div that has an iframe (imageFrame) inside of it. Ideally what I am looking to do is when you click on "Info" then my "subNav" appears and then let's say you click on "Contact". Now I have 2 iframes (subNavFrame + imageFrame) inside two differently named divs (subNav + imageStage). Then when a user clicks on "Design" I would like the "subNav" to display the list of projects and the ImageFrame to link to a blank.html (which is just to clear the div/iframe).

I currently have the functions in my index page as :

<script language="javascript">
function blankImageStage()\{\
document.getElementById('imageFrame').src='blank.html';
}</script>

and under my main navigation like so :
<div onClick="javascript:blankImageStage()" id="mainNav">

but nothing seems to happen ?
Any help or suggestions? I thank you ahead of time. I am just starting out using HTLM and javascript.
Hoping to learn more!

- Ty


just remove the \ characters from:

Code:
<script language="javascript">
function blankImageStage()\{\
   document.getElementById('imageFrame').src='blank.html';
}</script>
rickylau
since83 wrote:
<div onClick="javascript:blankImageStage()" id="mainNav">
Also i'm wondering if "javascript:" is necessary here (maybe it would cause another error too, as I know you may want to add "javascript:" when you are calling javascript function in <a href="xxx">)
Marcuzzo
in a href attribute yes, in Onclick you can leave it out.
I used to write that too but I soon found out that it isn't needed.
in programming you progress in trial and error
blueray
since83 wrote:
So Here is my dilemma: on my site http://www.since83.net, I am trying to make the div that contains my left side navigation (mainNav) to "onClick" with java and load a "blank.html" into another div that has an iframe (imageFrame) inside of it. Ideally what I am looking to do is when you click on "Info" then my "subNav" appears and then let's say you click on "Contact". Now I have 2 iframes (subNavFrame + imageFrame) inside two differently named divs (subNav + imageStage). Then when a user clicks on "Design" I would like the "subNav" to display the list of projects and the ImageFrame to link to a blank.html (which is just to clear the div/iframe).

I currently have the functions in my index page as :

<script language="javascript">
function blankImageStage()\{\
document.getElementById('imageFrame').src='blank.html';
}</script>

and under my main navigation like so :
<div onClick="javascript:blankImageStage()" id="mainNav">

but nothing seems to happen ?
Any help or suggestions? I thank you ahead of time. I am just starting out using HTLM and javascript.
Hoping to learn more!

- Ty


Do you go to build a page with XHTML or HTML ?
I assume you are using the former one .

It should be changed to,

Code:

<script language="text/javascript">/* <![CDATA[ */
function blankImageStage() {
   document.getElementById('imageFrame').src='blank.html';
}
/* ]]> */
</script>

and under my main navigation like so :
<div onclick="javascript:blankImageStage()" id="mainNav">


Also, I don't see div element have src attribute before. Check DOM1 and DOM2 for more information.
If there is a need to change the content of it.
Use src attribute of iframe, for external html file,
or, use innerHTML attribute of div, for html element tags.

- Eric
Marcuzzo
blueray wrote:
Also, I don't see div element have src attribute before. Check DOM1 and DOM2 for more information.
If there is a need to change the content of it.
Use src attribute of iframe, for external html file,
or, use innerHTML attribute of div, for html element tags.
- Eric



if you would have read the OP's message you would have seen

since83 wrote:
I am trying to make the div that contains my left side navigation (mainNav) to "onClick" with java and load a "blank.html" into another div that has an iframe (imageFrame) inside of it
blueray
Marcuzzo wrote:
blueray wrote:
Also, I don't see div element have src attribute before. Check DOM1 and DOM2 for more information.
If there is a need to change the content of it.
Use src attribute of iframe, for external html file,
or, use innerHTML attribute of div, for html element tags.
- Eric



if you would have read the OP's message you would have seen

since83 wrote:
I am trying to make the div that contains my left side navigation (mainNav) to "onClick" with java and load a "blank.html" into another div that has an iframe (imageFrame) inside of it


Marcuzzo

Yes, you are right !
I have missed that. Sad
Related topics

javascript function not being seen
Javascript Function Reference
Javascript Gallery Help (get some FRIH$)
JavaScript Help
Pls help, onmouseover popup image frm database

Help: Want to update an old inline JS feature.
AJAX tutorial [2nd part now updated]
Javascript function not working!!??
Expanding Javascript+CSS List
When clicked goes into input field??

Translate a code into javascript language (help needed)
$_Post Variable for Options from Select Types?
Textfield labels [resolved]
Tag question
onClick="window.open" - window issues
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.