469,275 Members | 1,871 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

javascript: in location bar

I am using IE 6.0

from
http://www.javaworld.com/javaworld/j...script-p2.html

I gather that
"If you need to test a number of command lines, you can reduce the
keystrokes by typing javascript: (remember the colon) in the Location
box. Navigator displays a "JavaScript typein" frame at the bottom of
the window. Type the command line you want to try, and press Enter. "

How can obtain a similiar "JavaScript typein" frame with IE 6.0, so
that I can enter *multiple* javascript command lines?

Thanks.

Mar 13 '06 #1
13 8080
John Smith said on 14/03/2006 8:00 AM AEST:
I am using IE 6.0

from
http://www.javaworld.com/javaworld/j...script-p2.html

I gather that
"If you need to test a number of command lines, you can reduce the
keystrokes by typing javascript: (remember the colon) in the Location
box. Navigator displays a "JavaScript typein" frame at the bottom of
the window. Type the command line you want to try, and press Enter. "

How can obtain a similiar "JavaScript typein" frame with IE 6.0, so
that I can enter *multiple* javascript command lines?


Use a text editor to write normal, indented code - maybe minimize
whitespace other than for indenting. Use find/replace to replace all
contiguous whitespace with a single space. Copy & paste that into the
command line.

When you get it working, save it as a bookmark.
--
Rob
Mar 14 '06 #2
RobG wrote:
John Smith said on 14/03/2006 8:00 AM AEST:
I am using IE 6.0

from
http://www.javaworld.com/javaworld/j...script-p2.html

I gather that
"If you need to test a number of command lines, you can reduce the
keystrokes by typing javascript: (remember the colon) in the Location
box. Navigator displays a "JavaScript typein" frame at the bottom of
the window. Type the command line you want to try, and press Enter. "

How can obtain a similiar "JavaScript typein" frame with IE 6.0, so
that I can enter *multiple* javascript command lines?


Use a text editor to write normal, indented code - maybe minimize
whitespace other than for indenting. Use find/replace to replace all
contiguous whitespace with a single space. Copy & paste that into the
command line.

When you get it working, save it as a bookmark.

when I paste my mini script at the location bar
javascript:function jsinput () {;
parent.MochaInput.document.write ("<b>JavaScript input</b>");
parent.MochaInput.document.write ("<form action=javascript:
target=MochaOutput>");
parent.MochaInput.document.write ("<textarea name='isindex' rows=5
cols=50>");
parent.MochaInput.document.write ("</textarea><BR>");
parent.MochaInput.document.write ("<input type='submit' value='Run'>");
parent.MochaInput.document.write ("</form>");
};

i got the following javascript error:
Expected '}'
(i tried removing all the ; at the end of each line and i still got the
same error)

apparently the location bar is only taking the first line of my script.
If i try putting all code on 1 line, with a ; at the end, i still got:
javascript:function jsinput () {parent.MochaInput.document.write
("<b>JavaScript input</b>") parent.MochaInput.document.write ("<form
action=javascript: target=MochaOutput>")
parent.MochaInput.document.write ("<textarea name='isindex' rows=5
cols=50>") parent.MochaInput.document.write ("</textarea><BR>")
parent.MochaInput.document.write ("<input type='submit' value='Run'>")
parent.MochaInput.document.write ("</form>") } ;

I got a javascript error that stated:
Expected ';'
Code 0

where is my mistake?

Mar 14 '06 #3
John Smith wrote:
when I paste my mini script at the location bar
javascript:function jsinput () {;
The ";" here is merely delimiting an empty statement.
parent.MochaInput.document.write ("<b>JavaScript input</b>");
The ";" here is required, unless the next statement is on the next line.

For the sake of code style, there should not be a space before the "("; it
is a method call, and the "(...)" part is the argument list that belongs to
the identifier of the called method.
parent.MochaInput.document.write ("<form action=javascript:
target=MochaOutput>");
parent.MochaInput.document.write ("<textarea name='isindex' rows=5
cols=50>");
parent.MochaInput.document.write ("</textarea><BR>");
parent.MochaInput.document.write ("<input type='submit' value='Run'>");
parent.MochaInput.document.write ("</form>");
};

i got the following javascript error:
Expected '}'
(i tried removing all the ; at the end of each line and i still got the
same error)

apparently the location bar is only taking the first line of my script.
Apparently that is not true for Gecko-based browsers. A newline in
copypasted code appears to be normalized to a space character.
If i try putting all code on 1 line, with a ; at the end, i still got:
javascript:function jsinput () {parent.MochaInput.document.write
("<b>JavaScript input</b>") parent.MochaInput.document.write ("<form
action=javascript: target=MochaOutput>")
parent.MochaInput.document.write ("<textarea name='isindex' rows=5
cols=50>") parent.MochaInput.document.write ("</textarea><BR>")
parent.MochaInput.document.write ("<input type='submit' value='Run'>")
parent.MochaInput.document.write ("</form>") } ;

I got a javascript error that stated:
Expected ';'
Code 0

where is my mistake?


You do not use a Gecko-based browser, such as Firefox, for testing
bookmarks. JScript's (IE's) error messages are often bizarre, if
not misleading, while SpiderMonkey's error messages are often much
more helpful, because they are often much more verbose. (Remember
the helicopter Microsoft joke?)

The error message I get in Firefox is

| Error: missing ; before statement
| Source file: javascript:function jsinput ()
| {parent.MochaInput.document.write("<b>JavaScript input</b>")
| parent.MochaInput.document.write ("<formaction=javascript:
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
| name='isindex' rows=5cols=50>") parent.MochaInput.document.write
| ("</textarea><BR>")parent.MochaInput.document.write ("<input type='submit'
| value='Run'>")parent.MochaInput.document.write ("</form>") } ;
| Line: 1, Column: 81
^^
| Source code:
| function jsinput () {parent.MochaInput.document.write("<b>JavaScript
| input</b>") parent.MochaInput.document.write ("<formaction=javascript:
-------------^
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
^ there's another one
| name='isindex' rows=5cols=50>") parent.MochaInput
^ and here, and so on.

That said, your "action=javascript:" is utter nonsense.
Search the archives for "pseudo-protocol".
PointedEars
Mar 14 '06 #4
#1)
PointedEars wrote:
"You do not use a Gecko-based browser, such as Firefox, for testing
bookmarks. "
I downloaded Firefox 1.5 and tried typing
javascript:alert("hello);
on the location bar. I purposedly missed the closing ", and expected a
javascript error message.
Instead once I hit "Enter", the screen does not change. no error
message, no popups, nothing.

Why?
#2)
"The error message I get in Firefox is
| Error: missing ; before statement
| Source file: javascript:function jsinput ()
| {parent.MochaInput.document.write("<b>JavaScript input</b>")
| parent.MochaInput.document.write ("<formaction=javascript:
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
| name='isindex' rows=5cols=50>") parent.MochaInput.document.write
| ("</textarea><BR>")parent.MochaInput.document.write ("<input
type='submit'
| value='Run'>")parent.MochaInput.document.write ("</form>") } ;
| Line: 1, Column: 81
^^
| Source code:
| function jsinput () {parent.MochaInput.document.write("<b>JavaScript
| input</b>") parent.MochaInput.document.write
("<formaction=javascript:
-------------^
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
^ there's another one
| name='isindex' rows=5cols=50>") parent.MochaInput
^ and here, and so on. "

Where did The error message I get in Firefox is
| Error: missing ; before statement
| Source file: javascript:function jsinput ()
| {parent.MochaInput.document.write("<b>JavaScript input</b>")
| parent.MochaInput.document.write ("<formaction=javascript:
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
| name='isindex' rows=5cols=50>") parent.MochaInput.document.write
| ("</textarea><BR>")parent.MochaInput.document.write ("<input
type='submit'
| value='Run'>")parent.MochaInput.document.write ("</form>") } ;
| Line: 1, Column: 81
^^
| Source code:
| function jsinput () {parent.MochaInput.document.write("<b>JavaScript
| input</b>") parent.MochaInput.document.write
("<formaction=javascript:
-------------^
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
^ there's another one
| name='isindex' rows=5cols=50>") parent.MochaInput
^ and here, and so on.
What commands did you give Firefox to view this error message?

Mar 14 '06 #5
#1)
PointedEars wrote:
"You do not use a Gecko-based browser, such as Firefox, for testing
bookmarks. "
I downloaded Firefox 1.5 and tried typing
javascript:alert("hello);
on the location bar. I purposedly missed the closing ", and expected a
javascript error message.
Instead once I hit "Enter", the screen does not change. no error
message, no popups, nothing.

Why?
#2)
"The error message I get in Firefox is
| Error: missing ; before statement
| Source file: javascript:function jsinput ()
| {parent.MochaInput.document.write("<b>JavaScript input</b>")
| parent.MochaInput.document.write ("<formaction=javascript:
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
| name='isindex' rows=5cols=50>") parent.MochaInput.document.write
| ("</textarea><BR>")parent.MochaInput.document.write ("<input
type='submit'
| value='Run'>")parent.MochaInput.document.write ("</form>") } ;
| Line: 1, Column: 81
^^
| Source code:
| function jsinput () {parent.MochaInput.document.write("<b>JavaScript
| input</b>") parent.MochaInput.document.write
("<formaction=javascript:
-------------^
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
^ there's another one
| name='isindex' rows=5cols=50>") parent.MochaInput
^ and here, and so on. "

Where did The error message I get in Firefox is
| Error: missing ; before statement
| Source file: javascript:function jsinput ()
| {parent.MochaInput.document.write("<b>JavaScript input</b>")
| parent.MochaInput.document.write ("<formaction=javascript:
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
| name='isindex' rows=5cols=50>") parent.MochaInput.document.write
| ("</textarea><BR>")parent.MochaInput.document.write ("<input
type='submit'
| value='Run'>")parent.MochaInput.document.write ("</form>") } ;
| Line: 1, Column: 81
^^
| Source code:
| function jsinput () {parent.MochaInput.document.write("<b>JavaScript
| input</b>") parent.MochaInput.document.write
("<formaction=javascript:
-------------^
| target=MochaOutput>")parent.MochaInput.document.wr ite ("<textarea
^ there's another one
| name='isindex' rows=5cols=50>") parent.MochaInput
^ and here, and so on.
What commands did you give Firefox to view this error message?

Mar 14 '06 #6
VK

John Smith wrote:
#1)
PointedEars wrote:
"You do not use a Gecko-based browser, such as Firefox, for testing
bookmarks. "
I downloaded Firefox 1.5 and tried typing
javascript:alert("hello);
on the location bar. I purposedly missed the closing ", and expected a
javascript error message.
Instead once I hit "Enter", the screen does not change. no error
message, no popups, nothing.

Why?


Because you looked at the wront place.

Choose Tools > JavaScript Console
Press Clear to remove accumulated stuff
Type whatever you want in the Evaluate string and press Enter.
Press Clear again, close the console, type javascript:alert("Hello);
and press Enter; open console again - here it is! :-)

Mar 14 '06 #7
Thanks for pointing out "Tools > JavaScript Console".

2 follow up questions:
1) The evaluate string is only 1 line. How do I evaluate a multiline
javascript snippet? Is there a better method than adding ; at the end
of each line and manually combining the say, 10 lines into 1 line?

e.g.
<SCRIPT>

function jsinput () {

parent.MochaInput.document.write ("<b>JavaScript input</b>")

parent.MochaInput.document.write ("<form action=javascript:
target=MochaOutput>")

parent.MochaInput.document.write ("<textarea name='isindex' rows=5
cols=50>")

parent.MochaInput.document.write ("</textarea><BR>")

parent.MochaInput.document.write ("<input type='submit' value='Run'>")

parent.MochaInput.document.write ("</form>")

}

</SCRIPT>

<FRAMESET ROWS="50%%,50%%">
<FRAME NAME="MochaOutput" SRC="about:blank">
<FRAME NAME="MochaInput" SRC="javascript:parent.jsinput()">
</FRAMESET>

#2) The above function jsinput() is called by another HTML element
(<FRAME> in this case). How do I include the HTML code in the
Evaluation process?

Mar 14 '06 #8
John Smith wrote:
#1)
PointedEars wrote:
"You do not use a Gecko-based browser, such as Firefox, for testing
bookmarks. "
I downloaded Firefox 1.5 and tried typing
javascript:alert("hello);
on the location bar. I purposedly missed the closing ", and expected a
javascript error message.
Instead once I hit "Enter", the screen does not change. no error
message, no popups, nothing.

Why?
Because you did not read the FAQ.
[...]
What commands did you give Firefox to view this error message?


Read the FAQ <URL:http://jibbering.com/faq/>, especially FAQ 4.43.

Furthermore, I recommend to install the Web Developer, Console^2,
and FireBug extensions.
PointedEars
Mar 14 '06 #9
John Smith wrote:
1) The evaluate string is only 1 line. How do I evaluate a multiline
javascript snippet? Is there a better method than adding ; at the end
of each line and manually combining the say, 10 lines into 1 line?
I use the JavaScript Console feature from ContextMenu Extensions, and
the Open Execute JS extension for this, unless I create a test case
HTML document.
e.g.
<SCRIPT>
The `type' attribute is required:

<script type="text/javascript">
[...]
Will you stop posting the same code over and over again?
Use Message-ID URIs for references if you have to:

news:11*********************@u72g2000cwu.googlegro ups.com
<FRAMESET ROWS="50%%,50%%"> ^^ ^^
Nonsense. <URL:http://validator.w3.org/>
<FRAME NAME="MochaOutput" SRC="about:blank">
Nonsense. about:blank is proprietary.
<FRAME NAME="MochaInput" SRC="javascript:parent.jsinput()">
Nonsense. javascript: is proprietary.
</FRAMESET>

#2) The above function jsinput() is called by another HTML element
(<FRAME> in this case). How do I include the HTML code in the
Evaluation process?


(Pardon?) You do not. HTML code is not script code.
And please learn to quote:

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
<URL:http://www.safalra.com/special/googlegroupsreply/>
PointedEars
Mar 14 '06 #10
Thomas 'PointedEars' Lahn wrote:
I use the JavaScript Console feature from ContextMenu Extensions, and
the Open Execute JS extension for this, unless I create a test case
HTML document.
I have installed the extensions Execute JS, Web Developer, and FireBug.
Use Message-ID URIs for references if you have to:

news:11*********************@u72g2000cwu.googlegro ups.com


i am a newbie with Google groups. how to include Message-ID URLs for
references ?
<FRAME NAME="MochaOutput" SRC="about:blank">


Nonsense. about:blank is proprietary.
<FRAME NAME="MochaInput" SRC="javascript:parent.jsinput()">


Nonsense. javascript: is proprietary.
</FRAMESET>


However, when I tried to use Execute JS,

I got "target has no properties" for parent.MochaInput

MochaInput is the "name" of a FRAMESET.
the SRC property is the jsinput() function that I would type in Execute
JS.

I could not define parent.MochaInput in my Execute JS window, since I
am not allowed to put in HTML source code.

How do I get around "target has no properties" in this case?

Mar 15 '06 #11
John Smith wrote:
Thomas 'PointedEars' Lahn wrote:
Use Message-ID URIs for references if you have to:

news:11*********************@u72g2000cwu.googlegro ups.com
i am a newbie with Google groups. how to include Message-ID URLs for
references ?


"show options", "View original". Then copy the part after the colon in
the Message-ID line, remove the "<" and ">" and prefix it with "news:"
Or just use a decent newsreader instead of buggy Google Groups.
However, when I tried to use Execute JS,

I got "target has no properties" for parent.MochaInput
`parent' is a property of Window objects; `parent.MochaInput' is equivalent
to `window.parent.MochaInput'. The script engine running in the Open
Execute JS window cannot know which target window is meant; instead parent
refers to `window.parent' of the ChromeWindow created by the extension (try
evaluating `window'). Therefore, it provides shortcut properties that you
should use here. They are explained when you open the Open Execute JS
window. The shortcut property for the client browser window is `cw'.
MochaInput is the "name" of a FRAMESET.
With this syntax, it can only be the name of a frame. Framesets have no
name.
the SRC property is the jsinput() function that I would type in Execute
JS.
As I said, it cannot work this way. The `javascript:' pseudo-protocol
is designed to build a HTML document with script code, to return a _string_
value. If you use javascript:jsinput() as _value_ of the `src' _attribute_
of a `frame' element, the return value of the jsinput() method, converted
to string, is used as body of the created document.
I could not define parent.MochaInput in my Execute JS window, since I ^^^^^^^^^^ am not allowed to put in HTML source code. ^^^^^^^^^^^^^^^^
Pardon?
How do I get around "target has no properties" in this case?


ISTM that you should understand what you are doing first.
PointedEars
Mar 15 '06 #12
Thomas 'PointedEars' Lahn wrote:
John Smith wrote:
Thomas 'PointedEars' Lahn wrote:
Use Message-ID URIs for references if you have to:

news:11*********************@u72g2000cwu.googlegro ups.com


i am a newbie with Google groups. how to include Message-ID URLs for
references ?


"show options", "View original". Then copy the part after the colon in
the Message-ID line, remove the "<" and ">" and prefix it with "news:"
Or just use a decent newsreader instead of buggy Google Groups.


I tried
news:30****************@PointedEars.de
I got:
"Outlook Express was unable to retrieve the requested message. It's
possible the message has expired or was removed from the server."

Mar 15 '06 #13
John Smith wrote:
Thomas 'PointedEars' Lahn wrote:
John Smith wrote:
> Thomas 'PointedEars' Lahn wrote:
>> Use Message-ID URIs for references if you have to:
>>
>> news:11*********************@u72g2000cwu.googlegro ups.com
>
> i am a newbie with Google groups. how to include Message-ID URLs for
> references ?


"show options", "View original". Then copy the part after the colon in
the Message-ID line, remove the "<" and ">" and prefix it with "news:"
Or just use a decent newsreader instead of buggy Google Groups.


I tried
news:30****************@PointedEars.de
I got:
"Outlook Express was unable to retrieve the requested message. It's
possible the message has expired or was removed from the server."


This URI in a Google Groups message creates a link. If you click that
link, you should be directed to the respective posting. The same works
if you use the part after the colon in the Advanced Group Search form,
or use http://groups.google.com/groups?selm=....

Accessing that URI within Windows (e.g. Start, Run) opens the assigned
NetNews client application, in this case Outlook Express. If you do not
have a newsserver configured for that application (which is likely if you
used only Google Groups until now), no request to such a server can be
made, hence the error message.

How to use USENET is off topic here. RTFM. STFW.

<URL:http://en.wikipedia.org/wiki/Usenet>
F'up2 poster (please reply only via e-mail)

PointedEars
Mar 15 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.