Ah HELP! Javascript

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
newbie2php
Forum Commoner
Posts: 35
Joined: Wed Nov 07, 2007 4:44 pm

Ah HELP! Javascript

Post by newbie2php »

Code: Select all

 
<script type="text/javascript"><!--
  var rowCount = 0;
  //add a new row to the table
  function addRow()
  {
  //add a row to the rows collection and get a reference to the newly added row
  var newRow = document.getElementById("custom-plan").insertRow();
 
  rowCount ++;
  var oCell = newRow.insertCell();
  oCell.innerHTML =  (I have some PHP echo'd out here which all works fine - just too much code to copy out)
 
  }
            
 //deletes the specified row from the table
 function removeRow(src)
 {
 
            
 var oRow = src.parentElement.parentElement;     
                
  //once the row reference is obtained, delete it passing in its rowIndex         
  document.getElementById("custom-plan").deleteRow(oRow.rowIndex);
                        
 }
 
The above code (abit messy I know!) works perfectly fine in I.E - but not so in firefox, here is a message I get (if this is the correct one for this javascript...)

Error: uncaught exception: Permission denied to call method Location.toString

I am unsure why the above code does not work, I am totally new to javascript and the above code is alot of copy and pasting. Is there anythig that springs out that may not be functional on firefox?
Last edited by newbie2php on Sat May 17, 2008 1:29 pm, edited 1 time in total.
suresh_2220
Forum Newbie
Posts: 23
Joined: Mon May 12, 2008 3:13 pm

Re: Ah HELP! Javascript

Post by suresh_2220 »

if you are posting code, please align it and post .
newbie2php
Forum Commoner
Posts: 35
Joined: Wed Nov 07, 2007 4:44 pm

Re: Ah HELP! Javascript

Post by newbie2php »

Hi - thanks...

The code is hopefully now layed out nicer.

There is obviously more code on the page, but its not relevent. I think its just the javascript commands that are not liked in firefox, and I was hoping that someone would be able to spot if anything looks out of place and may be causing this issue. Works fine in I.E

Thanks alot
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Ah HELP! Javascript

Post by Eran »

Methods insertRow() and deleteRow() are missing from your code, and Location.toString() is not called in what you've provided so it's hard to tell. Going by the error message, you have probably encountered a browser security measure that is enforced by Firefox but not by IE (so many of those floating around...).

I suggest you might try a Javascript library (I highly recommend jQuery - http://www.jquery.com) and enjoy the expertise and thousands of hours of development for cross-browser compliance that were invested in those projects.
Post Reply