How do I debug javascript in Safari?

S

Srikanth.S

Guest
Hi All,
This is my first post to this forum.I'm using Mac-Tiger 10.4.1 version and safari version 2.0 .My Questions are as follows,
1.How do I debug javascript code using safari browser.B'cos I can't able to find any javascript errors thru safari browser.
2.The following code is not executed well in Safari Browser.
Code:
document.write("<script type='text/javascript'>");
  document.write("some code here");
  document.write("document.forms[i].submit()");
  document.write("</script>");
I'm getting alert as the form has been submitted but i didn't get the desired output from the script.
Whether this type of form submission is correct or not? Waiting for ur kind replies.

Thanks in Advance,
Srikanth.S
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
Try shift-command(apple)-J that should open up the javascript console. If it does not, you need to turn on the debugging menu. You can do that by closing safari then opening up your terminal and typing this in:

Code:
defaults write com.apple.Safari IncludeDebugMenu 1

Then reopen safari and you should see a new debug menu in the menu bar.
 
OP
S

Srikanth.S

Guest
Murlyn,

Thanks for the reply.

Is there any difference in executing the follwing statement in safari browser[ Tiger & panther]

document.write("document.forms.submit()");

The above statment got executed in Panther [safari 1.X] but same statement is not executed in Tiger [safari 2.x].

Is there any difference?
Is there any work around to get executed?

Any help would be appreciated...
 
Joined
Jun 11, 2003
Messages
4,915
Reaction score
68
Points
48
Location
Mount Vernon, WA
Your Mac's Specs
MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
I am really not sure on this one, since Im not the best with javascript, hopefully someone else will be able to help you out on this one.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top