Re: Double-document.write('<scr'+'ipt>...) insert <br>-like space?
- From: Randy Webb <HikksNotAtHome@xxxxxxx>
- Date: Fri, 24 Aug 2007 22:34:40 -0400
Richard wrote the following on 8/24/2007 9:16 PM:
<top posting corrected>
On Aug 24, 5:23 pm, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:Richard said the following on 8/24/2007 6:10 PM:
<div id="right" >What is with all that voodoo scripting by breaking up tags that have no
<script type="text/javascript">
if (IsThis)
document.write('<img src="images/foo.gif" />');
else
{
document.write('<div id="too_right"><scr' + 'ipt type="text/
javascript" src="http://external.com/script.js"></scr' + 'ipt></
div>');
bearing on what it was attempting to do rather than breaking up the
sequence that should be broken up?
document.write('<script type="text/javascript"
src="someFile.js"><\/script>')
}Then why not just write the image tag anyway? Or, is the src attribute
</script>
</div>
Now here's the good part:http://external.com/script.jsreturns (wait
for it) 'document.write("<img src="..." />");'
different?
if (!IsThis){document.write('<div id="too_right">')}
document.write('<img src="images/foo.gif">');
if (!IsThis){document.write('</div>')}
And for crying out loud, stop using XHTML on the web. Especially when
90% or so of the web doesn't even know what it is.
<signature snipped that shouldn't have been quoted>
1. Do you mean the 'scr' + 'ipt' thing? I had some browser get
confused and end the real script tag once. Perhaps it is unnecessary
these days.
Yes, that is what I meant. It isn't the word script that ends it, it is the character sequence </ that can end it - it is up to the browser. Escape the / and it becomes a moot issue.
2. The goal is to sometimes embed the <img> and sometimes embed the
<script>.
And that is why I asked if the external file is going to write the same image tag, just using a div wrapper being the only difference.
3. I have to do it this way because I do not own script.js; I cannot
control what it does, and currently, it does a document.write(). If I
want to use it based on a JavaScript value, I have to do this nested
document.write weirdness processing at page parse-time. I would prefer
to use div.innerHTML = ..., but as the external script returns
"document.write(...)", that is not an option.
Sure it is. It is quite simple actually. Stick the script tag in a container with innerHTML, read the text of the script block, parse out the img data and insert it where you want. The only 4 browsers that will have a problem with that are NS6.1/NS6.2(Win), iCab3 (mac) and IE5.2 (mac). Of those four, two are virtually obsolete and I would gander that one of the others is virtually obsolete as well.
4. Why XHTML? XML editors prefer it, and they will tell me if I am
missing something. While 90% of the web might not know what it is,
they do not seem to mind it.
Serve it with a proper mime type and tell me that again. Without the proper MIME type, every browser is going to read it as tag soup HTML (read garbage HTML) and the GIGO (Garbage In, Garbage Out) principle applies.
With the proper MIME Type, IE won't even display it as tag soup HTML, it will prompt the user to download the file.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.
- References:
- Prev by Date: Math formulas easy editor like tinyMCE
- Next by Date: Re: setting form parameter with same name as submit buttons
- Previous by thread: Re: Double-document.write('<scr'+'ipt>...) insert <br>-like space?
- Next by thread: Double-document.write('<scr'+'ipt>...) insert <br>-like space?
- Index(es):