| Author |
alert is not working
|
Jagdeep Sharma
Ranch Hand
Joined: May 24, 2010
Posts: 121
|
|
guys,
I am having a sample code. Which is not running properly. It displays instead of alert. My code is below.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
The browser does not understand that the script tag in the alert is not the closing tag.
Instead of looking at the html code, lets look at some JavaScript.
Your problem is equivalent to
See the issue there? We want the whole string, but it chops it off early at the ' after Eric and throws an error. In the case of the HTML it stops it at the script tag in the code and than renders whatever else as text on the page.
So how would be fix the JavaScript example? We would escape the '
And it would work fine.
What we need to do for the HTML issue is to break up the script tag into two parts.
The browser will no longer see the closing script tag when it is rendering the page.
Eric
|
 |
Jagdeep Sharma
Ranch Hand
Joined: May 24, 2010
Posts: 121
|
|
Eric Pascarello wrote:The browser does not understand that the script tag in the alert is not the closing tag.
Instead of looking at the html code, lets look at some JavaScript.
Your problem is equivalent to
See the issue there? We want the whole string, but it chops it off early at the ' after Eric and throws an error. In the case of the HTML it stops it at the script tag in the code and than renders whatever else as text on the page.
So how would be fix the JavaScript example? We would escape the '
And it would work fine.
What we need to do for the HTML issue is to break up the script tag into two parts.
The browser will no longer see the closing script tag when it is rendering the page.
Eric
You may be right. But if i remove xhtml doctype and use
It works. Now i am unable to understand what is happening here.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
So you are saying you changed it to look like:
I would still expect issues there.
|
 |
Jagdeep Sharma
Ranch Hand
Joined: May 24, 2010
Posts: 121
|
|
Eric Pascarello wrote:So you are saying you changed it to look like:
I would still expect issues there.
Remove doctype. It will work.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
And what horrible browser is this?
In the end you need the doc type on the page.
Eric
|
 |
Jagdeep Sharma
Ranch Hand
Joined: May 24, 2010
Posts: 121
|
|
Eric Pascarello wrote:And what horrible browser is this?
In the end you need the doc type on the page.
Eric
As far as i know. if you use html not xhtml. You dont need doctype. Please correct if i am wrong. Please help. If you remove doctype the code above displays alert box.
|
 |
 |
|
|
subject: alert is not working
|
|
|