473,388 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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 8261
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.