How to get text from javascript alert box
Topics related to client-side programming language.
Post questions and answers about JavaScript, Ajax, or jQuery codes and scripts.
-
JanMolendijk
- Posts:282
- Location:Holland Rotterdam
How to get text from javascript alert box
Good evening (dutch-time) I have a javascript what can copy text to a clip-board + it has a button to show the item-list in a alert-box.
But can`t find out how I can select the text from the alertbox.
Hope you can help me out.... ?
Code: Select all
<body>
<table WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
<td align="center">
<table width="100%">
<tr>
<td WIDTH="100%" align="center"><form name="history">
<p><font
face="ARIEL,HELVETICA" SIZE="-1"><input name="command" type="text" value size="20"> <input type="button"
value="Add to List" onclick="f_store(document.history.command.value)"> <input
name="history" type="button" value="Show List" onclick="f_print()"> </font> </p>
</form>
<p align="center"><font
face="ARIEL,HELVETICA" SIZE="-1"><script language="JavaScript">
<!-- hide it ...
function MakeArray( n ) {
if( n <= 0 ) {
this.length = 0;
return this;
}
this.length = n;
for( var i = 1; i <= n; i++ ) {
this[ i ] = 0;
}
return this;
}
var history = new MakeArray( 15 );
var index = 0;
var cmmnd = 1;
function f_store( sTR ) {
var i;
if( index >= history.length ) {
for( i = 1; i < history.length; i++ )
history[i-1] = history[i];
index = history.length - 1;
}
history[ index ] = cmmnd + ":" + sTR;
++cmmnd;
++index;
document.history.command.value="";
}
function f_print() {
var allCmmnds, i;
allCmmnds = "";
for( i = 0; i < index; i++ )
allCmmnds += history[i] + "\n";
alert( allCmmnds );
}
</script>
Admin
Posts:805
Hello,
You cannot get /copy the text directly from the alert box, but you can get the text (value) from the variable that is added in the alert() function.
So, identify in the javascript code where the text come from, the variable that store the text, and you can get the text from that variable.
In your code, the text is stored in the "history" variable, which is an array. You can get the text you want from that array.
Try study the f_print() function in your code, which contain the alert() instruction.
JanMolendijk
Posts:282
Thanks for the support I tried already things with history + f_print
also studied those a little before I asked coursesweb but I shall
when my head is cleared do those staps again.
(vv sorry for my late response incase)
Similar Topics
- Speech to text without https
General Forum
First post
Pleasant Coursesweb,
Is their anything posible without https for speech to text fill-in ?
Or must I turn my SSL document on the XAMPP-server ?
Last post
Hello,
I don't know about speech to text fill-in.
Anyway, I want to inform you that this forum will be closed for register or posting.
Any...
- Hour and Minutes togheter in Javascript
JavaScript - jQuery - Ajax
First post
Dear Coursesweb I can not find out how to add the hours + minutes togheter.
<SCRIPT LANGUAGE= JavaScript >
day = new Date()
hr =...
Last post
See and use the following example:
<script>
var day = new Date();
let hr = day.getHours();
let mn = day.getMinutes();
let se =...
- Display message to every minute in Javascript
JavaScript - jQuery - Ajax
First post
Hello,
On eatch minute from the current hour I wanna have an message
I can not find out how to complete
I hope to get something like this (code...
Last post
If you only want to display a message to every minute, just use the setInterval() function. It calls a function repeatedly, over and over again, at...