Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

javascript: and about: Protocols Not Working

24 views
Skip to first unread message

Gene Wirchenko

unread,
Nov 30, 2011, 9:28:43 PM11/30/11
to
Dear JavaScripters:

The text that I am using refers to javascript: and about:
protocols. None of the examples will run on my system (IE 9 on
Windows 7).

For
javascript:Date()
I get nothing. For
about:cache
and
about:plugins
I get a message of "Navigation to the webpage was canceled / What you
can try: / - Retype the address."

I have looked for settings to enable these and have found
nothing. What am I missing, please?

Sincerely,

Gene Wirchenko

Martin Honnen

unread,
Dec 1, 2011, 5:53:27 AM12/1/11
to
Gene Wirchenko wrote:
> Dear JavaScripters:
>
> The text that I am using refers to javascript: and about:
> protocols. None of the examples will run on my system (IE 9 on
> Windows 7).
>
> For
> javascript:Date()
> I get nothing.

Well where/how do you use it exactly? When I type that line into IE 9's
address bar and hit enter it displays the current date (e.g. Thu Dec 1
11:51:52 UTC+0100 2011) in the browser window.

> For
> about:cache
> and
> about:plugins
> I get a message of "Navigation to the webpage was canceled / What you
> can try: / - Retype the address."
>
> I have looked for settings to enable these and have found
> nothing. What am I missing, please?

Well that about stuff is something Netscape and later Mozilla
implemented, I have never heard that Microsoft browsers supported that.




--

Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/

Richard Cornford

unread,
Dec 1, 2011, 7:29:16 AM12/1/11
to
On Dec 1, 10:53 am, Martin Honnen wrote:
> Gene Wirchenko wrote:
>> Dear JavaScripters:
>
>> The text that I am using refers to javascript: and about:
>> protocols. None of the examples will run on my system (IE 9 on
>> Windows 7).
>
>> For
>> javascript:Date()
>> I get nothing.
>
> Well where/how do you use it exactly? When I type that line into
> IE 9's address bar and hit enter it displays the current date
> (e.g. Thu Dec 1 11:51:52 UTC+0100 2011) in the browser window.

IE 9 seems to have an odd characteristic where is you _paste_ a
javascript pseudo-protocol URL into the address bar then it does not
include the 'javascript:' bit from the beginning, and you have to re-
type it manually.

>> For
>
>> about:cache
>> and
>> about:plugins
>> I get a message of "Navigation to the webpage was canceled / What
>> you can try: / - Retype the address."
>
>> I have looked for settings to enable these and have found
>> nothing. What am I missing, please?
>
> Well that about stuff is something Netscape and later Mozilla
> implemented, I have never heard that Microsoft browsers supported
> that.

Yes, Microsoft provide other means of accessing that sort of
information. The cache from:-

Tools->Internet Options...->General(tab)->Browsing history(section)-
>Settings(button)->View Files(button).

- and the plug-ins from:-

Tools->Internet Options...->Programs(tab)->Manage add-ons(button).

Richard.
Message has been deleted

Richard Cornford

unread,
Dec 1, 2011, 7:03:42 AM12/1/11
to
On Dec 1, 10:53 am, Martin Honnen wrote:
> Gene Wirchenko wrote:
>> Dear JavaScripters:
>
>> The text that I am using refers to javascript: and about:
>> protocols. None of the examples will run on my system (IE 9 on
>> Windows 7).
>
>> For
>> javascript:Date()
>> I get nothing.
>
> Well where/how do you use it exactly? When I type that line into
> IE 9's address bar and hit enter it displays the current date
> (e.g. Thu Dec 1 11:51:52 UTC+0100 2011) in the browser window.

IE 9 seems to have an odd characteristic where is you _paste_ a
javascript pseudo-protocol URL into the address bar then it does not
include the 'javascript:' bit from the beginning, and you have to re-
type it manually.

>> For
>
>> about:cache
>> and
>> about:plugins
>> I get a message of "Navigation to the webpage was canceled / What
>> you can try: / - Retype the address."
>
>> I have looked for settings to enable these and have found
>> nothing. What am I missing, please?
>
> Well that about stuff is something Netscape and later Mozilla
> implemented, I have never heard that Microsoft browsers supported
> that.

Martin Honnen

unread,
Dec 1, 2011, 8:02:53 AM12/1/11
to
Tim Streater wrote:
> In article <4ed75ca4$0$6638$9b4e...@newsspool2.arcor-online.net>,
> Martin Honnen <maho...@yahoo.de> wrote:
>
>> Gene Wirchenko wrote:
>> > Dear JavaScripters:
>> >
>> > The text that I am using refers to javascript: and about:
>> > protocols. None of the examples will run on my system (IE 9 on
>> > Windows 7).
>> >
>> > For
>> > javascript:Date()
>> > I get nothing.
>>
>> Well where/how do you use it exactly? When I type that line into IE
>> 9's address bar and hit enter it displays the current date (e.g. Thu
>> Dec 1 11:51:52 UTC+0100 2011) in the browser window.
>
> I get nothing in Safari either. But I find this unsurprising, since
> you've not told anyone to do anything with the date info that Date()
> returns. If I go javascript:alert(Date()); then I get an alert panel up
> with the date/time in it. Or I can do javascript:console.info(Date());
> and get the time/date in the error console window as expected.
>
> Or I can do javascript:document.write(Date()); and then it appears in
> the browser window as expected. If IE9 is putting it there without
> document.write I'd call that a bug.

Not at all, with a javascript: URL you are supposed to write some
Javascript code that is evaluated and whose value is then displayed in
the window or frame. At least that was the original intent when the
syntax was introduced. You even had to use
void 0
at the end of your Javascript code if you did not want the result of the
code to be displayed in the window or frame.

Martin Honnen

unread,
Dec 1, 2011, 8:19:51 AM12/1/11
to
Martin Honnen wrote:

> Not at all, with a javascript: URL you are supposed to write some
> Javascript code that is evaluated and whose value is then displayed in
> the window or frame.

http://home.arcor.de/martin.honnen/html/test2011120101.html is an
example, the iframe content is generated by a javascript: URL, works in
IE 9, Firefox, Google, Opera. The link works in IE 9, Firefox, Opera but
not in Chrome, but I don't get any error message so I am not sure
whether that is some kind of security restriction.

Gene Wirchenko

unread,
Dec 1, 2011, 3:14:39 PM12/1/11
to
On Thu, 01 Dec 2011 11:53:27 +0100, Martin Honnen <maho...@yahoo.de>
wrote:

>Gene Wirchenko wrote:
>> Dear JavaScripters:
>>
>> The text that I am using refers to javascript: and about:
>> protocols. None of the examples will run on my system (IE 9 on
>> Windows 7).
>>
>> For
>> javascript:Date()
>> I get nothing.
>
>Well where/how do you use it exactly? When I type that line into IE 9's
>address bar and hit enter it displays the current date (e.g. Thu Dec 1
>11:51:52 UTC+0100 2011) in the browser window.

Exactly as you do. When I do that, I get nothing.

> > For
>> about:cache
>> and
>> about:plugins
>> I get a message of "Navigation to the webpage was canceled / What you
>> can try: / - Retype the address."
>>
>> I have looked for settings to enable these and have found
>> nothing. What am I missing, please?
>
>Well that about stuff is something Netscape and later Mozilla
>implemented, I have never heard that Microsoft browsers supported that.

Why do I get a message "Navigation to the webpage was canceled"?
Cancelled? That implies that my entry was recognised but disallowed.
And so I went searching for a setting to allow it: a waste of time.

Why not "Unrecognised protocol"?

Sincerely,

Gene Wirchenko

Erwin Moller

unread,
Dec 2, 2011, 4:01:30 AM12/2/11
to
On 12/1/2011 9:14 PM, Gene Wirchenko wrote:
> On Thu, 01 Dec 2011 11:53:27 +0100, Martin Honnen<maho...@yahoo.de>
> wrote:
>
>> Gene Wirchenko wrote:
>>> Dear JavaScripters:
>>>
>>> The text that I am using refers to javascript: and about:
>>> protocols. None of the examples will run on my system (IE 9 on
>>> Windows 7).
>>>
>>> For
>>> javascript:Date()
>>> I get nothing.
>>
>> Well where/how do you use it exactly? When I type that line into IE 9's
>> address bar and hit enter it displays the current date (e.g. Thu Dec 1
>> 11:51:52 UTC+0100 2011) in the browser window.
>
> Exactly as you do. When I do that, I get nothing.


Hi Gene,

Don't do that. ;-)
You can best compare the pseudoprotocol (javascript:X in an url, where X
is some javascript command) as follows:

<a href="javascript:X;">click me to execute javascript</a>
almost equals:
<script type="text/javascript">
X
</script>

Where X is your javascript.


So, if you do this (without any pseudoprotocol):
<script type="text/javascript">
Date();
</script>

what do you expect to happen?


Regards,
Erwin Moller



--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens

Jukka K. Korpela

unread,
Dec 2, 2011, 4:31:15 AM12/2/11
to
2011-12-01 15:19, Martin Honnen wrote:

> http://home.arcor.de/martin.honnen/html/test2011120101.html is an
> example, the iframe content is generated by a javascript: URL, works in
> IE 9, Firefox, Google, Opera. The link works in IE 9, Firefox, Opera but
> not in Chrome, but I don't get any error message so I am not sure
> whether that is some kind of security restriction.

I would expect javascript: URLs to behave differently depending on
browser, in sufficiently complicated cases at least. There is no
specification on the exact meaning and treatment of such URLs.

By the way, your test code shows, on one of my browsers,
"Today is Fri Dec 02 2011 11:08:04 GMT+0200 (Suomen normaaliaika)."
What's that odd parenthetic note there? I know what it means... but why
does it appear in text in English? :-)
Implicit Date to string conversions aren't really suitable even for
demos, as they may inadvertantly demonstrate the lack of proper
localization in JavaScript and its implementations.

But returning to javascript: URLs, yesterday I stumbled across a bug
(some key links not working at all on some modern browsers), which
turned out to be caused by legacy code that uses an href attribute with
javascript: URL _and_ target="_blank". Isolated to a simple case:
http://www.cs.tut.fi/~jkorpela/js/target.html
On Firefox 8, the "link" opens a new tab with about:blank contents. With
the target attribute removed,
http://www.cs.tut.fi/~jkorpela/js/targetless.html
it works as intended.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Martin Honnen

unread,
Dec 2, 2011, 9:43:11 AM12/2/11
to
Jukka K. Korpela wrote:



> But returning to javascript: URLs, yesterday I stumbled across a bug
> (some key links not working at all on some modern browsers), which
> turned out to be caused by legacy code that uses an href attribute with
> javascript: URL _and_ target="_blank". Isolated to a simple case:
> http://www.cs.tut.fi/~jkorpela/js/target.html
> On Firefox 8, the "link" opens a new tab with about:blank contents. With
> the target attribute removed,
> http://www.cs.tut.fi/~jkorpela/js/targetless.html
> it works as intended.


With the target being set, the browser first opens a new tab and in the
contents of that tab evaluates the Javascript code. As there is no
content at all in that tab the function call "openUp()" to a function
named "openUp" fails as no function is defined at all in the new tab. At
least that is how Mozilla and Opera do it, Chrome does what you want.
An attempt to "fix" that or at least to demonstrate the issue is
http://home.arcor.de/martin.honnen/html/test2011120201.html but it now
only gives a popup in Firefox and Chrome, Opera blocks it. And of course
with Firefox you now have a new empty tab and a popup window.

So none of that is really a viable approach.

Jukka K. Korpela

unread,
Dec 2, 2011, 12:57:05 PM12/2/11
to
2011-12-02 16:43, Martin Honnen wrote:

>> legacy code that uses an href attribute with
>> javascript: URL _and_ target="_blank".
[...]
> With the target being set, the browser first opens a new tab and in the
> contents of that tab evaluates the Javascript code. As there is no
> content at all in that tab the function call "openUp()" to a function
> named "openUp" fails as no function is defined at all in the new tab.

Sounds like a simple explanation, and Firefox indeed shows an error
message about openUp being undefined.

> At least that is how Mozilla and Opera do it, Chrome does what you want.

Well, this wasn't really my code, or even my code. :-) Just an
interesting observation. And although the fix would be simple, it seems
to be legacy code that nobody wants to take care of.

> So none of that is really a viable approach.

Indeed, if someone wants to open a web page in a new window with
specific properties, it is surely much better to set up a normal link,
then add an onclick handler that creates a window for the link to use,
so that the page works fine when JavaScript is off and in a
cross-browser way when it is on. But I'm afraid there's a lot of code
around that uses javascript: URLs in href attributes instead of any
robust approach.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Gene Wirchenko

unread,
Dec 2, 2011, 3:35:01 PM12/2/11
to
On Fri, 02 Dec 2011 10:01:30 +0100, Erwin Moller
<Since_humans_read_this...@spamyourself.com> wrote:

[snip]

>Don't do that. ;-)
>You can best compare the pseudoprotocol (javascript:X in an url, where X
>is some javascript command) as follows:
>
><a href="javascript:X;">click me to execute javascript</a>
>almost equals:
><script type="text/javascript">
>X
></script>
>
>Where X is your javascript.

>So, if you do this (without any pseudoprotocol):
><script type="text/javascript">
>Date();
></script>
>
>what do you expect to happen?

Mr. Moller, I have RTFM. javascript: is documented as replacing
the current document with the value generated by the code. Yes, this
is different from a <script> code block.

Just to be sure, I tried
javascript:document.write(Date());
and got the same results, namely nothing.

Sincerely,

Gene Wirchenko
Message has been deleted

Gene Wirchenko

unread,
Dec 2, 2011, 4:56:28 PM12/2/11
to
On Fri, 02 Dec 2011 20:39:38 +0000, Tim Streater
<timst...@greenbee.net> wrote:

>In article <ucdid7hleubscelfn...@4ax.com>,
> Gene Wirchenko <ge...@ocis.net> wrote:
>
>> On Fri, 02 Dec 2011 10:01:30 +0100, Erwin Moller
>> <Since_humans_read_this...@spamyourself.com> wrote:
>
>> >what do you expect to happen?
>>
>> Mr. Moller, I have RTFM. javascript: is documented as replacing
>> the current document with the value generated by the code.
>
>Documented *where* ??

In my text. I thought I found one on the Web, but I can not now.
At least one other person in-thread has stated it, too.

>> Yes, this is different from a <script> code block.
>>
>> Just to be sure, I tried
>> javascript:document.write(Date());
>> and got the same results, namely nothing.
>
>And where did you try this? In a browser's address bar, or within a
>script, or what?

The address bar. Before posting, it did not even occur to me to
put it in a page.

Sincerely,

Gene Wirchenko

Jake Jarvis

unread,
Dec 2, 2011, 5:01:05 PM12/2/11
to
On 02.12.2011 21:39, Tim Streater wrote:
> In article <ucdid7hleubscelfn...@4ax.com>,
> Gene Wirchenko <ge...@ocis.net> wrote:
>
>> On Fri, 02 Dec 2011 10:01:30 +0100, Erwin Moller
>> <Since_humans_read_this...@spamyourself.com> wrote:
>
>> >what do you expect to happen?
>>
>> Mr. Moller, I have RTFM. javascript: is documented as replacing
>> the current document with the value generated by the code.
>
> Documented *where* ??
>
<snip>

Netscape, presumably the inventors, documented it at

http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/guide/advtopic.html#1004952

or already in the 'JavaScript [1.1] Guide for Navigator 3.0' accessible
at

http://web.archive.org/web/20040212093615/http://developer.netscape.com/docs/manuals/archive.html

for example - and then they got copied - and this group's FAQ mentions
that behavior (unfortunately FAQ's down at the moment at least for me).

--
Jake Jarvis
Message has been deleted

Dr J R Stockton

unread,
Dec 3, 2011, 2:13:37 PM12/3/11
to
In comp.lang.javascript message <1ohid7pebhai3ksa47bi7cpi91flu5olju@4ax.
com>, Fri, 2 Dec 2011 13:56:28, Gene Wirchenko <ge...@ocis.net> posted:

>
> In my text. I thought I found one on the Web, but I can not now.
>At least one other person in-thread has stated it, too.
>

You should not believe everything that you read on the Web or in
newsgroups. I write with authority there; some of it I wrote myself.

--
(c) John Stockton, nr London UK. replyYYWW merlyn demon co uk Turnpike 6.05.
Web <http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.

Arno Welzel

unread,
Dec 4, 2011, 9:46:20 AM12/4/11
to
Gene Wirchenko, 2011-12-01 03:28:
"about:" is not a "protocol" and are no standard either. So don't expect
this to work universally in any browser.

Using "javascript:" is also a bad idea - better implement an event
handler for user interaction.



--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de

Bwig Zomberi

unread,
Dec 6, 2011, 1:11:09 AM12/6/11
to
Gene Wirchenko wrote:
> For
> javascript:Date()

This does not have to work unless you use window.alert() or
document.write().

Some browsers support just "javascript:Date()" - they are being
user-friendly, that's all.


> I get nothing. For
> about:cache
> and
> about:plugins

These would work in Opera/Firefox. I don't think IE ever supported them.

--
Bwig Zomberi
0 new messages