I have a beautiful lil' javascript function called preview. I have tested it, and it works fine, however when I try to call it from the onclick handler of button like so:


Code:
onClick="window.status='loading preview box...'; preview();"


the status bar changes like it should and then my javascript console gives me this:

Quote:
JavaScript - http://localhost:8080/vanillaforum/posting.php
Event thread: click
Error:
name: TypeError
message: Statement on line 1: The Object does not implement [[Call]]
Backtrace:
Line 1 of script
window.status = "loading preview box...";
preview();
At unknown location
[statement source code not available]



I know it can call functions because alert() works fine.
Need more context to understand.
I don't believe window.status is the correct method...
button looks like so:


Code:
<input type="button" tabindex="6" name="preview" class="mainoption" value="{L_PREVIEW}" onClick="window.status='loading preview box...'; preview();" />


function preview() works fine when called in script, however, it gives the following errors when called by the onclick function (or any input event handlers for that matter, such as onkeyup of a textarea)
Quote:
JavaScript - http://localhost:8080/vanillaforum/posting.php
Event thread: click
Error:
name: TypeError
message: Statement on line 1: The Object does not implement [[Call]]
Backtrace:
Line 1 of script
window.status = "loading preview box...";
preview();
At unknown location
[statement source code not available]


window.status is fine. it does exactly what it should. and without it I still get the same errors.
It seems probable (especially after our discussion on IM) that you've discovered some sort of bug/glitch in JS. Solution: workaround.
wierd, cause it showed up in multiple browsers. anywho, I just added a timer and eliminated the preview button.
Did you try...
window.defaultStatus='Loading preview box...'
pyro_xp2k wrote:
Did you try...
window.defaultStatus='Loading preview box...'


the Window status has absolutely nothing to do with it

at least read the debug output if you aren't going to listen to me.

I already tried removing all status bar stuff whatsoever. it had no effect.
Quote:
window.status is fine. it does exactly what it should. and without it I still get the same errors.


Im not a noob, I know the steps of the debugging process. Ive been programming for the last 8 years....
>> [turns a fan in elfprince13's direction]
>> I'm guessing you're talking about something like below.
Well I tried putting

Code:
<input type="button" tabindex="6" name="preview" class="mainoption" value="{L_PREVIEW}"  onClick="window.status='loading preview box...'; preview();" />

in a simple page and then a really simple function preview() and it works fine in FF and IE and it works so I'm lost...

Code:
<html>
   <head>
      <script>
         function preview(){
         alert("stuff stuff stuff");
         }
      </script>
   </head>
   <body>
      <form name="testform">
         <input type="button" tabindex="6" name="preview" class="mainoption" value="{L_PREVIEW}"  onClick="window.status='loading preview box...'; preview();" />
      </form>
   </body>
</html>
sorry for blowing up like that, however Im starting to get irritated with people who try to offer help (a good thing, always grateful for it) and the go back and say stuff thats already been said, and that wouldn't need to be said again if you read back 3 or 4 posts for context.

Ive tried it in IE, FF, and Opera, all of them tell me it can't call the preview function, even though its there, and it works from anywhere else in the script except form event handlers. Neutral
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement