Bug?

18 views
Skip to first unread message

ja...@shaped.ca

unread,
Aug 21, 2007, 8:25:46 PM8/21/07
to Prototype: Core
4014: "src='://javascript:void(0)'><\/script>");

shouldn't this be:
4014: "src='http://javascript:void(0)'><\/script>");

ie6 was tossing errors on-load, but only when mod-rewrite was turned
on and my server was dumping a full web page back to this request,
which shouldn't even hit the server, right?

:)

Mislav Marohnić

unread,
Aug 22, 2007, 4:41:44 AM8/22/07
to prototy...@googlegroups.com
I'm not sure why Sam put it in there. The correct form should be:

    var src = "javascript:void(0)";
    if (location.protocol == "https:") src = "https://" + src;
    document.write("<script id=__onDOMContentLoaded defer src='" + src + "'><\/script>");

Sam, can you replace this?

Wiktor Ihárosi

unread,
Aug 22, 2007, 4:38:03 PM8/22/07
to Prototype: Core

Mislav Marohnić wrote:
> I'm not sure why Sam put it in there. The correct form should be:

I think Sam had reason to write this. I reread Dean Edwards's - who
else? :) - post about the window.onload and one of the last comment
says with https you can remove the protocol.
http://dean.edwards.name/weblog/2006/06/again/?full#comment56361

That is, you can replace javascript:void(0) to :// because
javascript:void(0) is unsecure content for IE if I am right.
http://dean.edwards.name/weblog/2006/06/again/?full#comment5776

I checked Dean's base2 code and it uses simply :// too without
checking the protocol. I suppose this does not send any http requests.

"@MSIE.+win": {
init: function() {
this.base();
// Matthias Miller/Mark Wubben/Paul Sowden/Me
document.write("<script id=__ready defer src=//:><\/script>");
document.all.__ready.onreadystatechange = function() {
if (this.readyState == "complete") {
this.removeNode(); // tidy
DOMContentLoaded.fire();
}
};
}
},

http://base2.googlecode.com/svn/trunk/lib/src/base2-dom.js

Mislav Marohnić

unread,
Aug 22, 2007, 5:19:25 PM8/22/07
to prototy...@googlegroups.com
On 8/22/07, Wiktor Ihárosi <iharosi...@gmail.com> wrote:

I think Sam had reason to write this. I reread Dean Edwards's - who
else? :) - post about the window.onload and one of the last comment
says with https you can remove the protocol.
http://dean.edwards.name/weblog/2006/06/again/?full#comment56361

Nice research, Wiktor. Thanks

Jason, can you confirm for sure that your setup makes HTTP requests? Can you give us more detailed information? Thanks

Richard Quadling

unread,
Aug 23, 2007, 3:52:26 AM8/23/07
to prototy...@googlegroups.com
I'm on Windows IE7, using Sambar Server and my server.log file has
requests like this ...

127.0.0.1 - - [21/Aug/2007:16:58:19 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 426 0 "http://dev.salesops.rquadling/testradio.html"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
.NET CLR 2.0.50727; "
127.0.0.1 - - [21/Aug/2007:16:58:19 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 426 0 "http://dev.salesops.rquadling/testradio.html"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
.NET CLR 2.0.50727; "
127.0.0.1 - - [21/Aug/2007:16:59:01 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 426 0 "http://dev.salesops.rquadling/testradio.html"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
.NET CLR 2.0.50727; "
127.0.0.1 - - [21/Aug/2007:16:59:01 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 426 0 "http://dev.salesops.rquadling/testradio.html"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
.NET CLR 2.0.50727; "
127.0.0.1 - - [21/Aug/2007:17:00:16 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 426 0 "http://dev.salesops.rquadling/testradio.html"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
.NET CLR 2.0.50727; "
127.0.0.1 - - [21/Aug/2007:17:00:16 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 426 0 "http://dev.salesops.rquadling/testradio.html"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
.NET CLR 2.0.50727; "
127.0.0.1 - - [21/Aug/2007:17:02:15 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 426 0 "http://dev.salesops.rquadling/testradio.html"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
.NET CLR 2.0.50727; "
127.0.0.1 - - [21/Aug/2007:17:02:15 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 426 0 "http://dev.salesops.rquadling/testradio.html"
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322;
.NET CLR 2.0.50727; "
127.0.0.1 - - [22/Aug/2007:09:22:08 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 435 79
"http://dev.salesops.rquadling/index.php?Action=9.1.1" "Mozilla/4.0
(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR
2.0.50727; "
127.0.0.1 - - [22/Aug/2007:09:22:08 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 435 79
"http://dev.salesops.rquadling/index.php?Action=9.1.1" "Mozilla/4.0
(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR
2.0.50727; "
127.0.0.1 - - [22/Aug/2007:09:22:17 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 435 0
"http://dev.salesops.rquadling/index.php?Action=9.1.1" "Mozilla/4.0
(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR
2.0.50727; "
127.0.0.1 - - [22/Aug/2007:09:22:17 +0100] "GET /://javascript:void(0)
HTTP/1.1" 404 435 0
"http://dev.salesops.rquadling/index.php?Action=9.1.1" "Mozilla/4.0
(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR
2.0.50727; "

They always appear in pairs and only for IE.


--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

Richard Quadling

unread,
Aug 23, 2007, 3:52:57 AM8/23/07
to prototy...@googlegroups.com
Using FF and/or the patch previously mentioned and no requests are made.

On 22/08/07, Mislav Marohnić <mislav....@gmail.com> wrote:

Mislav Marohnić

unread,
Aug 23, 2007, 3:58:49 AM8/23/07
to prototy...@googlegroups.com
On 8/23/07, Richard Quadling <rqua...@googlemail.com> wrote:
Using FF and/or the patch previously mentioned and no requests are made.

Can you please try

src=//:

... like in Base2 and see if there are requests. Thanks

Richard Quadling

unread,
Aug 23, 2007, 4:02:22 AM8/23/07
to prototy...@googlegroups.com

Being a numpty, my current code is ...

var src = "javascript:void(0)";
if (location.protocol == "https:") src = "https://" + src;
document.write("<script id=__onDOMContentLoaded defer src='" + src
+ "'><\/script>");

This needs to become what? I don't know what Base2 is (sorry).

Mislav Marohnić

unread,
Aug 23, 2007, 5:30:45 AM8/23/07
to prototy...@googlegroups.com
On 8/23/07, Richard Quadling <rqua...@googlemail.com> wrote:

This needs to become what? I don't know what Base2 is (sorry).

document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");

Richard Quadling

unread,
Aug 23, 2007, 5:35:55 AM8/23/07
to prototy...@googlegroups.com
On 23/08/07, Mislav Marohnić <mislav....@gmail.com> wrote:

Works fine in IE7 and FF using 1.6.0_rc0. No requests made.

Wiktor Ihárosi

unread,
Aug 23, 2007, 7:46:31 AM8/23/07
to Prototype: Core
On Aug 23, 11:35 am, "Richard Quadling" <rquadl...@googlemail.com>
wrote:

> > document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
> Works fine in IE7 and FF using 1.6.0_rc0. No requests made.

Great! :)

ps: I obviously meant //: when I wrote ://. sorry for the typo...

Richard Quadling

unread,
Aug 23, 2007, 8:03:08 AM8/23/07
to prototy...@googlegroups.com

Ah.

That's now generating requests.

127.0.0.1 - - [23/Aug/2007:13:01:42 +0100] "GET /:// HTTP/1.1" 404 434
78 "http://dev.salesops.rquadling/index.php?Action=1.1D" "Mozilla/4.0


(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR
2.0.50727; "

127.0.0.1 - - [23/Aug/2007:13:01:42 +0100] "GET /:// HTTP/1.1" 404 434
78 "http://dev.salesops.rquadling/index.php?Action=1.1D" "Mozilla/4.0


(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR
2.0.50727; "

But only for IE, not FF2.

Wiktor Ihárosi

unread,
Aug 23, 2007, 8:10:59 AM8/23/07
to Prototype: Core
On Aug 23, 2:03 pm, "Richard Quadling" <rquadl...@googlemail.com>
wrote:

> That's now generating requests.

I think I was not clear enough. The correct and working syntax is //:
which Mislav mentioned. In my first letter I made a typo, but Mislav
wrote the correct syntax for you. He is right, document.write("<script
id=__onDOMContentLoaded defer src=//:><\/script>"); is right!

Sorry for confusing things! :(

Richard Quadling

unread,
Aug 23, 2007, 8:23:36 AM8/23/07
to prototy...@googlegroups.com
On 23/08/07, Wiktor Ihárosi <iharosi...@gmail.com> wrote:
>

No problems. Back working again now.

Nick

unread,
Sep 6, 2007, 11:57:18 AM9/6/07
to Prototype: Core
This was throwing errors in IE7 for me ( "Expected ';'" at line 2 ).
Swapping //: for :// fixed this error too.

On Aug 23, 1:23 pm, "Richard Quadling" <rquadl...@googlemail.com>
wrote:

jdalton

unread,
Sep 6, 2007, 1:40:22 PM9/6/07
to Prototype: Core

Guys,

the code document.write("<script id=__onDOMContentLoaded defer
src=//:><\/script>");

is for IE mainly and anything else that falls into that category. No
need to work for the others.....

The reason he uses '//:' its a trick that works for both HTTPS and
HTTP. Its less code than doing all those checks and works...
I use this on my HTTPS app and it works flawlessly.

I also use the //: for some initail image sources and have no issues
in any browsers.

Here is how I used my version:

document.write('<script id="_ieDomLoad" defer="defer" src="//:"
onreadystatechange="Event.getInterceptor(document, \'DOMContentLoaded
\').notify()"></script>');

Event.observe(document, 'DOMContentLoaded', function(){$
('_ieDomLoad').remove();});

jdalton

unread,
Sep 6, 2007, 1:41:47 PM9/6/07
to Prototype: Core
I forgot to mention that without that little trick on an HTTPS site in
IE you get an ugly warning dialog...

Ryan Gahl

unread,
Sep 6, 2007, 2:16:44 PM9/6/07
to prototy...@googlegroups.com
This technique is also used in Extjs.

It covers most cases, sure. However, it potentially fails in situations where resource lazy loading is used heavily. In our widget framework, each widget is responsible for encapsulating its own resource requirements, so it sometimes possible to have code like this loaded well after the initial page was loaded (for instance, the app did not consume a widget at startup that required Ext or proto, hypothetically, but does at some later point).

So... what happens is this document.write is called within a context where the DOM has already been loaded. There should just be some simple check for the state of document.body before even going through this step (if DOM loaded document.body exists), and just do the notify immediately in that case.

Resource lazy loading is increasingly important as the complexity of an application (read: not website with minor ajax enhancements) increases, and now both Ext and proto require me to do some fairly hackish stuff with redefining document.write to account for these situations).



On 9/6/07, jdalton <jdalt...@gmail.com> wrote:

I forgot to mention that without that little trick on an HTTPS site in
IE you get an ugly warning dialog...



--
Ryan Gahl
Manager, Senior Software Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
--
Architect
WebWidgetry.com / MashupStudio.com
Future Home of the World's First Complete Web Platform
--
Inquire: 1-262-951-6727
Blog: http://www.someElement.com

jdalton

unread,
Sep 6, 2007, 7:09:19 PM9/6/07
to Prototype: Core
Ryan what you speak of is a slightly different conversation.
I believe carried on in another post recently:
http://groups.google.com/group/prototype-core/browse_thread/thread/3cdb0b85c9997999

The thread dealt with weather calling
document.observe("contentLoaded", ...); should fire immediately if the
window.onload event has already fired...

The same could be said for the Event.observe(window, 'load', ...).
That it too should fire instantly if window.onload has already been
triggered.

However, on a separate note, I am concerned about the real
window.onload event triggering while in the middle of executing the
observers for the emulated "contentLoaded".
So far though, I have gotten 0% feedback from the Core team about this
concern.

Reply all
Reply to author
Forward
0 new messages