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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window.Alert Command - Paragraphs

Status
Not open for further replies.

Tamrak

MIS
Jan 18, 2001
213
US
Good morning:

I have a command called "Window.Alert" and would like to enhance it.

1. How can I put them into two or three paragraphs? For example:

Window.alert ("Thank you for ..........

In a meantime,............. ")

I would like the pop-up box to contain two or three paragraphs.

2. Will the hyperlink work in the Window.alert command?

For example:

Window.alert ("Thank you for ..............

In a meantime, please visit "

3. Does it have any character limitation? I am unsure about the 256 characters.

Please let me know. I hope this will not be too difficult. Thank you.
 
1.
Code:
Window.alert ("Thank you for ..........[b]\n\n[/b]In a meantime,.............  ")
2. No
3. Not that I know of, but you'll be safe going over 256. You may want to consider what is going to go outside the realm of the visible desktop if you put too many on (this has happened to me before)

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Thank you for your assistant. I used the string \n\n and it still does not work. I will try to find some workaround. Thanks again.
 
Tamrak, \n is the javascript escape character for a carriage return, it should do what you're asking. Copy and paste this into a new .html document and pull it up in IE or your browser of choice. You'll see that there will be line breaks between the text:
Code:
<script language="javascript">
alert("This is a test\n\n\n\n\n\n\n\nto ensure line breaks\n\n\n\n\n\n\n\nappear between these words");
</script>

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Kaht,

Thank you for your time.

I decided to change the script to VBScript and used the MsgBox command.

I created a variable Chr(10) & Chr(13), which seems to work without having to worry about the limitation.

You have guided me enough on this issue.

PB1 = Chr(10) & Chr(13)
StrMsg = "Thank you for using the form."
StrMsg = StrMsg & PB1 & "Meanwhile, we invite you to review the from. Let us know if you have any questions about this process. Thanks again."
Msgbox StrMsg,,"Confirmation"

Thanks again for your time.

Tamrak
 
If that still limits you too much, consider using a floating div instead. You can make it do almost anything the msgbox can do, with greater flexibility and style.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hi Tsdragon,

I am not familiar with floating div. Anyway, can I include the hyperlink into it? I am curious. Thanks.
 
This may be overkill for what you want, but the code is free and it works well. You may be able to take some of the code anyway. You can even drag it around on the screen.


If that's too much, we can give you some much simpler code.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
TSDRAGON,

Thank you for your post. You have earned a star.

Tamrak

 
Thank you for your assistant. I used the string \n\n and it still does not work.

Maybe because you are using "Window.alert" instead of "window.alert" or just "alert"?

You have to remember that JavaScript is case-sensitive.

There is no reason why \n won't work.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Make sure that your using quotes instead of apostrophes too. I don't think that \n works inside apostrophes (it doesn't in some other languages).

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
It definitely is window.alert being wrongly used as Window.alert even window is not necessary (or is understood) here. There is no such limit of \n inside "" or '' whatever they are called.

For the op's information, if you use vbs, there are standard constants line break+carriage return. vbcrlf is chr(13)&chr(10), vbnewline is chr(13)&chr(10) or chr(10) platform-dependent, vbcr is chr(13) and vblf is chr(10). So your Chr(10) & Chr(13) though works is highly unconventional which is least adhere to convention(s) and may pose problem for other users if you use it as a habit.
 
tsuji: you're right. I'm getting my programming languages mixed up again. As soon as I read your post it occurred to me how I could easily have tested that before I posted: just key this into the address box:

javascript: alert('one\ntwo');

(It works)

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top