Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Boxes in JScript

Status
Not open for further replies.

MarkMeerten

Programmer
Aug 20, 2003
37
BE
Hello,
I'm trying to put a bit of user - interaction in my JScript.
I want to display a confirm - or promt messagebox in the script.
e.g.: window.confirm("Here goes my text");

If i call the script in a html file with <body onload...> no problem.

But i want to use it in a .js - file. If i put this line of code in my script i always get errormessages!
Even if i leave &quot;window.&quot; out of the command it doesn't work!!

Does anyone have an example of a working JScript (*.js) where a messagebox is displayed??

Thanx,

Mark
 
var a=confirm('Click OK if this works');
if (a) alert('This works');

<script src=&quot;confirm.js&quot;></script>


Seems OK to me. The bug must be elsewhere.

----------
I'm willing to trade custom scripts for... [see profile]
 
----------
var a=confirm('Click OK if this works');
if (a) alert('This works');

<script src=&quot;confirm.js&quot;></script>


Seems OK to me. The bug must be elsewhere.
----------

What do you mean with 'the bug must be elsewhere???

I've tried your example but is doesn't work.

I want to lose the <script> tags!!

bye


 
Well it works fine on my PC.

You cannot lose those script tags - they are tags that call the external .JS file :/

Add the <SCRIPT.../SCRIPT> to your HTML file and put the code in a blank text file called confirm.js

----------
I'm willing to trade custom scripts for... [see profile]
 

His example does work, mate.

You put this inside a file called &quot;confirm.js&quot; ...
Code:
  var a=confirm('Click OK if this works');
   if (a) alert('This works');

And then your link to that .js file goes in your main page ...
Code:
<script src=&quot;confirm.js&quot;></script>
 
I've also made it work in a html file but i don't want to use it with a html file but just with a js - file
i want to call the JScript in a commandbox using the command wscript.exe \\path_to_the_script\myscript.js

We use JScript to solve all kinds of small probs in our compagny. After the JScript is ready we spread it with SMS to all PC's... That's why i can't use a html file...

I know it's a bit silly to use JScript for such things but it's compagny policy!! :-(

So if anyone has an idea to do this without a html file... Let me know!
 
I know that WScript.Echo(''); is the same as alert('');

I dunno about confirm though :/

----------
I'm willing to trade custom scripts for... [see profile]
 
Thanx for all the suggestions guy's but....

I was looking in my books and i found the following in &quot;Windows 2000 Scripting Bible&quot;:

&quot;Dialog and input boxes are associated with the window object. Unfortunately, the window object is nog available in WHS&quot;

I'll spare you all the things that came out of my mouth when i read this (i'm scarred that i'll be kicked of this forum if i'll post them here ;-) )

So i'll have to find another workaround for my prob!!

Thanx for you're fast answers!!!

Greetz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top