PDA

View Full Version : [DHTML] Click to Activate Override Wizard



jscheuer1
04-28-2007, 02:40 PM
1) CODE TITLE: Click to Activate Override Wizard

2) AUTHOR NAME/NOTES: jscheuer1

3) DESCRIPTION: A wizard that generates (from a working multimedia object's* HTML code) the code required to override this silly 'click to activate' business in IE, Opera, perhaps others.

The wizard works in (tested with) IE 6+, FF 1.5.0.11, Opera 9.01, and outputs code that can be used in any browser that supports document.write. It also outputs non-javascript enabled fall back code.

4) URL TO CODE: http://home.comcast.net/~jscheuer1/side/click_to_activate_w.htm



*Multimedia Objects like:


Flash
QuickTime
Media Player
etc.

thetestingsite
04-28-2007, 05:12 PM
Nice script John (as usual). I tested it in IE7, FF 2.0.0.2/2.0.0.3 on Windows XP (Home and Pro) and it works fine.

tech_support
04-29-2007, 04:13 AM
Ha. Nice script.
But, your page doesn't validate:
http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fhome.comcast.net%2F~jscheuer1%2Fside%2Fclick_to_activate_w.htm

jscheuer1
04-29-2007, 04:34 AM
Ha. Nice script.
But, your page doesn't validate:
http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fhome.comcast.net%2F~jscheuer1%2Fside%2Fclick_to_activate_w.htm

Those are errors produced because the validator is trying to validate javascript code as HTML code. It is the validator that is in error.

The actual code is valid.

tech_support
04-29-2007, 04:39 AM
Oh, ok.
BTW, I love the "Supreme Commander Coder"

jscheuer1
04-29-2007, 05:29 AM
Oh, ok.
BTW, I love the "Supreme Commander Coder"

Thanks, and just to make the validator happy, I made the script it barfed on use a hex entity. Usually it barfs on stuff like so:


document.write('<a name="bob">Bob</a>');

Because it doesn't see the a tag as open (can't have a tags inside a <script> tag), but does see it getting closed. That can be fixed by escaping the /. However, this time it interpreted a regular expression as a close tag, completely erroneous on its part. Easiest fix for that was making the code external, but then I thought about it and found I could substitute \x3c for <.

mwinter
04-29-2007, 07:20 AM
Those are errors produced because the validator is trying to validate javascript code as HTML code.

No, it isn't. If it did, it would complain about:



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title//<body<script type="text/javascript">
<p id=">
</>

but it's perfectly valid. All that the validator is trying to do is find the end of the script element so it looks for anything that matches an end-tag production.



It is the validator that is in error.

You should know better than to write things like that.



The actual code is valid.

No, it wasn't. Among the minimisation features of SGML (some of which are enabled in HTML) are unclosed end-tags. These are like normal end-tags except the TAGC (>) is omitted. However, an unclosed end-tag must be followed by a STAGO (<) or ETAGO (</). Instead, it was followed by a comma.

Mike

DimX
04-29-2007, 07:50 AM
Easiest fix for that was making the code external, but then I thought about it and found I could substitute \x3c for <.
What about enclosing the script in a CDATA block?

jscheuer1
04-29-2007, 08:13 AM
It wasn't a tag at all.

mwinter
04-29-2007, 08:28 AM
What about enclosing the script in a CDATA block?

The content model for a script element (in HTML) is CDATA, therefore a marked section won't be interpreted as such; "<![CDATA[" and "]]>" are just plain character sequences.



It wasn't a tag at all.

As far as a SGML parser is concerned, it is: it parses like one, therefore it is one. The fact that you didn't intend for it to be an end-tag, and that it isn't an end-tag for an element recognised by HTML is of no consequence.

Mike

jscheuer1
04-29-2007, 08:57 AM
These are all fine tuning points that have little to do with the usefulness of the code. I did fix the wizard code so that it will validate. I am under no illusions though that this will make it work in any greater number of browsers than it did to begin with. I'm almost certain that it will not. The code it outputs is a different matter and, I believe will work as stated:

"in any browser that supports document.write"

This should be taken to also mean browsers which supported the multimedia object to begin with.

Focusing on the validator and its limitations or lack thereof in this regard is of no consequence to the script's usefulness for its stated purpose. It is pretty much off topic for the thread and the submit sub-forum here.