Board Logo

Run javascript from menu item choice.
jem - 9/15/2009 at 10:52 AM

OK, either my programming is a bit rusty (highly possible) OR I'm missing something.

What I am trying to do is clean up our website from using iFrames to CSS.

I have setup a 3 column, header footer layour using CSS DIV's.
What I am now trying to do is make the menu item choices only change the CONTENT DIV. I tried a simple javascript as per the example in the documentation and it does not run.

Here is the code for the main page

<div id="Header">
<div align="center">Header
<script type="text/javascript">
new menu (MENU_ITEMS, MENU_TPL);
<div class="threecol">
<div class="colmid">
<div class="colleft">
<div class="col1">
<!-- Column 1 start -->
<!-- Column 1 end -->
<div class="col2">
<!-- Column 2 start -->
<!-- Column 2 end -->
<div class="col3">

<!-- Column 3 start -->

<!-- Column 3 end -->
<div id="footer">

And here is the item.js code

/* Tigra Menu items structure */
var MENU_ITEMS = [
['Home', null],
['Products', null, null,
['test div link', 'javascript:action("Hello World!");'],
['test mail to', 'mailto:[email protected]']

The mailto works but the javascript does not.
When I goto click on the 'test div likn' I get no response.
The status bar shows 'javascript:action(' and that is all. it should show javascript:action("Hello World!");

Any help would be appreciated

jem - 9/15/2009 at 11:56 AM

OK, I changed the text slightly to swap ' and " as follows


['test div link', 'javascript:alert("Hello World!");'],


['test div link', "javascript:alert('Hello World!');"],

and now it works fine.

Any suggestions as to why?

Back to forum: