|
I have found the following but it needs a bit of tweaking:
String.prototype.strip_tags = function() {
return this.replace(/<\/?[a-z]+>/gi, '');
}
How do I print my voice mail?
|
|
|
|
|
Try something like this:
function stripTags(value, exclude, tagsToExclude)
{
if ("string" != typeof(value) || 0 == value.length) return "";
if ("boolean" != typeof(exclude)) exclude = true;
var arrTags = null;
var tagCount = 0;
switch(typeof(tagsToExclude))
{
case "object":
if (Array == tagsToExclude.constructor)
{
tagCount = tagsToExclude.length;
if (0 == tagCount)
{
arrTags = new Array();
for(var key in tagsToExclude)
{
arrTags.push(tagsToExclude[key]);
tagCount++;
}
}
else
{
arrTags = tagsToExclude;
}
}
break;
case "string":
var len = arguments.length;
tagCount = len - 2;
arrTags = new Array(tagCount);
arrTags[0] = tagsToExclude;
for(var i = 3; i < len; i++)
{
arrTags[i - 2] = arguments[i];
}
break;
}
if (!exclude && 0 == tagCount) return value;
var reTag = /<\/?([a-z0-9]+)[^>]*>/gi;
if (0 == tagCount)
{
return value.replace(reTag, "");
}
else if (exclude)
{
return value.replace(reTag, function($0, $1)
{
var tagName = $1.toLowerCase();
var found = false;
for(var i=0; i < tagCount && !found; i++)
{
if (arrTags[i] == tagName) found = true;
}
return found ? $0 : "";
});
}
else
{
return value.replace(reTag, function($0, $1)
{
var tagName = $1.toLowerCase();
var found = false;
for(var i=0; i < tagCount && !found; i++)
{
if (arrTags[i] == tagName) found = true;
}
return found ? "" : $0;
});
}
}
value = stripTags(value, exclude, "p", "b", "i", "iframe");
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
I want to know how to detect when a button on the keyboard is pressed and what button.I am specifically looking for a way to tell when the up arrow,down arrow,left arrrow,right arrow is pressed.thanx.
|
|
|
|
|
onkeydown onkeyup onkeypress
How do I print my voice mail?
|
|
|
|
|
In those events, you would use the window.event.keyCode or keyChar properties to see which key was pressed.
--Steve P
|
|
|
|
|
Does anyone know how to detect whats happening in a frame?
Such as when a link is clicked the page is refreshed and even its source code?If you do know please let me know.
|
|
|
|
|
I imagine it's possible.
If you can get the FRAMEs window object then you could get it's document object and from there you can capture just about any event.
Cheers
How do I print my voice mail?
|
|
|
|
|
Hi,
I am building a website which opens a site map in a child window (window.open - popup window) which displays in links to navigate for users.
How do i do this -
When the users clicks on the child window link, the parent window must load that particular page.
any suggestions? easy one i think...
$iva
|
|
|
|
|
window.parent.location.href="index1.htm"
I think that how you do it...
How do I print my voice mail?
|
|
|
|
|
Hi there guys,
Have created an OCX for use in a web page, and used Visual Studio Installer to package it into bith .msi and .cab formats. In the page that it is to be used in, I am using an <OBJECT> tag with the CODEBASE attribute set to point to the .CAB (Have also tried with the MSI and same problem...." . I am getting the message telling me that need to download and install it, but after clicking Yes, nothing seems to happen.
Is there a step that I am missing, or could anyone point me to a tutorial on this and Digital Signatures?
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
It sounds like the CAB file wasn't found in your codebase path, or the version in your object tag is greater than the version of the control in the cab. Your tag should look something like this:
<OBJECT classid="CLSID:MYBIGGUID"<br />
codebase=../BIN/MYCONTROL.cab#Version=1,0,0,21"<br />
id="rtfChartViewer"<br />
style="height:100%;LEFT:0px;TOP:0px;WIDTH:100%;" VIEWASTEXT><br />
</OBJECT>
|
|
|
|
|
Hi
i need an special Regular Expression, but i don't know how to create them. Maybe one of you can help me.
Sitation:
$query = "SELECT * FROM table WHERE att = '$d-Name$';
i have to replace "$d-Name$" with an value - like this:
$query = "SELECT * FROM table WHERE att = 'jakob'
thx 4 any help
jazz
|
|
|
|
|
Do you really need a regular expression for this? I mean, it's a simple string search replace so using a regex will be a bit of an overkill.
What language are you using?
~javier lozano
(blog || email)
|
|
|
|
|
I just discovered that <HTML> tag will be automatically removed from text entered in a <textarea> when <textarea> loses, then regain input focus. How can I get around it?
Example: Entering this into <textarea>...
<HTML><BODY>login<INPUT name=login><BR>password <INPUT name=login></BODY></HTML>
will get trimmed down to:
login<INPUT name=login> <BR>password <INPUT name=login>
Thanks!
Norman Fung
|
|
|
|
|
A textarea won't AFAIK remove anything....
However htmlarea which replaces an textarea does remove html and body tags. See htmlarea (here on CP) for possible solutions.
How do I print my voice mail?
|
|
|
|
|
Hi,
I'm developing an application that takes credit cards. I do not want to go back to the server when the client swipes the card to break the mag-stripe data apart, so I would like to do this client side using JavaScript.
I can write the JavaScript code, I just don't know how to code the input statement in HTML to call my script on a text change of a textbox.
Thanks,
Glenn
|
|
|
|
|
Check your form elements inside onsubmit
How do I print my voice mail?
|
|
|
|
|
Try this code. This will put a text box on the browser and when you change the text and step back on to browser, will call teh function 'yourfunction()'
------------
document.write("")
------------------------
|
|
|
|
|
This is my code for calculating Variance between two dates
function presentDate(startDate, endDate) {<br />
var ierr = 1 ;<br />
<br />
var roundDays = 1 ;<br />
<br />
if(startDate != '') {<br />
if(!isNaN(Date.parse( startDate ))) {<br />
var s = new Date(Date.parse(startDate)) ;<br />
ierr = 0 ;<br />
}<br />
}<br />
<br />
if(endDate != '' && ierr != 1) {<br />
if(!isNaN(Date.parse( endDate ))) {<br />
var e = new Date(Date.parse(endDate)) ;<br />
<br />
var temp = suycDateDiff( s, e, 'd', roundDays ) ;<br />
}else{<br />
ierr = 1;<br />
}<br />
}else{<br />
ierr = 1;<br />
}<br />
<br />
if ( temp != null && ierr != 1 ) <br />
<br />
return temp.toString() ;<br />
}<br />
<br />
function suycDateDiff( start, end, interval, rounding ) {<br />
<br />
var iOut = 0;<br />
<br />
var startMsg = "Check the Start Date and End Date\n"<br />
startMsg += "must be a valid date format.\n\n"<br />
startMsg += "Please try again." ;<br />
<br />
var intervalMsg = "Sorry the dateAdd function only accepts\n"<br />
intervalMsg += "d, h, m OR s intervals.\n\n"<br />
intervalMsg += "Please try again." ;<br />
<br />
var bufferA = Date.parse( start ) ;<br />
var bufferB = Date.parse( end ) ;<br />
<br />
if ( isNaN (bufferA) || isNaN (bufferB) ) {<br />
alert( startMsg ) ;<br />
return null ;<br />
}<br />
<br />
if ( interval.charAt == 'undefined' ) {<br />
alert( intervalMsg ) ;<br />
return null ;<br />
}<br />
<br />
var number = bufferB-bufferA ;<br />
<br />
switch (interval.charAt(0))<br />
{<br />
case 'd': case 'D': <br />
iOut = parseInt(number / 86400000) ;<br />
if(rounding) iOut += parseInt((number % 86400000)/43200001) ;<br />
break ;<br />
case 'h': case 'H':<br />
iOut = parseInt(number / 3600000 ) ;<br />
if(rounding) iOut += parseInt((number % 3600000)/1800001) ;<br />
break ;<br />
case 'm': case 'M':<br />
iOut = parseInt(number / 60000 ) ;<br />
if(rounding) iOut += parseInt((number % 60000)/30001) ;<br />
break ;<br />
case 's': case 'S':<br />
iOut = parseInt(number / 1000 ) ;<br />
if(rounding) iOut += parseInt((number % 1000)/501) ;<br />
break ;<br />
default:<br />
alert(intervalMsg) ;<br />
return null ;<br />
}<br />
<br />
return iOut ;<br />
}
Now again, I need to find the variance between these two dates excluding the non-working days i.e Thirsday and Friday.
Help kindly appreciated.
Regards,
The Phantom.
|
|
|
|
|
Hey,
I've worked out the DateVariance function. The function below returns the number of non-working days (non-Thursdays/Fridays) between the two given dates (startDate and endDate ).
Here is the function:
function DateVariance(startDate, endDate)
{
var diffMS = (endDate.getTime() - startDate.getTime());
var days = Math.floor(diffMS / (1000 * 3600 * 24));
if(days == 0)
return days;
var nonworkdays = 0;
var weeks = Math.floor(days / 7);
if(weeks > 0)
{
days -= weeks;
nonworkdays += (weeks * 2);
}
if(days > 0)
{
var dayofweek = startDate.getDay();
if(dayofweek < 5)
{
if(dayofweek == 4)
nonworkdays++;
else
{
if(days > (4 - dayofweek))
nonworkdays += 2;
}
}
else
{
if(dayofweek == 5 && days == 6)
nonworkdays++;
else if(dayofweek == 6 && days >= 5)
nonworkdays += (days == 5 ? 1:2);
}
}
return (days-nonworkdays);
}
Basically what this does is as follows:
1) Get difference (in milliseconds) between the two different dates
2) Convert those milliseconds into number of whole days between the two dates
3) Convert that number of days into number of whole weeks between the two dates
4) For every week between the two dates, add 2 to a variable called nonworkdays -- this var will keep track of the non-work days between the two dates
5) Now, subtract out (7 * weeks) from days so we're left with a number for days that is less than 7.
6) With that number of days (if it is greater than 0) perform the following to add more work days:
6a) If the day of the week is Thursday, add 1 more work day to the total non-work days
6b) If the day of the week is less than Thursday (i.e. Sunday-Wednesday) add 2 work days if, by adding the remaining number of days to the current day of the week, we pass wednesday (in which case we're passing Thursday and Friday, so we have to add 2 to nonworkdays ), otherwise, don't add anything to nonworkdays (because we don't pass Thursday and Friday).
6c) If the day of the week is Friday AND days is 6, then we need to add 1 to nonworkdays (because otherwise we'll land on a Thursday).
6d) If the day of the week is Saturday, add 2 non work days if days==6 (because otherwise we will land on Friday) or 1 non work day if days==5 (because otherwise we will lang on Thursday).
7) Finally, return days - nonworkdays which will be the total non-work days between the two given dates.
[EDIT] I removed the document.write line from the function. Obviously, that was there for testing purposes only! [/EDIT]
Hope that helps!
Sincerely,
Alexander Wiseman
|
|
|
|
|
I make a web page which contain two frames. The upper frame is to play some MPEG-2 video in sequence and the lower frame is an sliding text (simialr to HTML marquee effect) written in java applet. I use IE6.0 browser and window XP. However, I encounter some problems:
First, I write HTML using the <object> tag to play the video and use javascript to control playing the next video when one is finished. Everything is fine except that when the first video is finished and loading the next video to play, the sliding text which is written in java applet will stop for a while. (I test under local LAN and the stop times is about 1-2 seconds) I want to ask why this problem happen and can this problem be avoided? If yes, how to avoid this?
Second, I try doing the same things as the first question. However, in this time, I use HTML+TIME instead of pure HTML + javascript. The problem is very strange this time. The sliding text no longer stopped when finish playing one video and everything is all right. But after 2-3 hours, the IE6.0 is no responding and everything is stopped (the videos and the sliding text). During these 2-3 hours period, I haven't touch the computer and I do not have any screen saver opening. I just let the browser to continuous to play the videos sequentially. So I want to ask why the browser will have no responding in this case and how to solve this problem.
Thank You.
|
|
|
|
|
Hi Friends,
I am using JMF to run video files in JSP. Should i install JMF in all client PC?. If not, u tell me the solution to overcome.
by,
senthil
senthil
|
|
|
|
|
Hi all,
Please anyone knows how to add day to a Date excluding weekends, preferrable language is Javascript.
function DateAdd(startDate, numDays, numMonths, numYears)<br />
{<br />
var returnDate = new Date(startDate.getTime()) ;<br />
var yearsToAdd = numYears ; <br />
var month = returnDate.getMonth() + numMonths + 1 ;<br />
<br />
if ( month > 11 )<br />
{<br />
yearsToAdd = Math.floor((month+1)/12) ;<br />
<br />
month -= 12*yearsToAdd ;<br />
<br />
yearsToAdd += numYears ;<br />
}<br />
<br />
returnDate.setMonth(month) ;<br />
<br />
returnDate.setFullYear(returnDate.getFullYear() + yearsToAdd) ;<br />
<br />
returnDate.setTime(returnDate.getTime()+60000*60*24*numDays) ;<br />
<br />
return returnDate ;<br />
}
Now I need to exclude non-working days, i.e Thursday and Friday.
Help kindly appreciated.
Thanks
The Phantom.
|
|
|
|
|
Hi,
I think this algorithm should work for what you are trying to do (it assumes that Thursday and Friday are the "non-work days":
<br />
function DateAdd(startDate, numDays, numMonths, numYears)<br />
{<br />
var returnDate = new Date(startDate.getTime()) ;<br />
var yearsToAdd = numYears ; <br />
var month = returnDate.getMonth() + numMonths + 1 ;<br />
<br />
if ( month > 11 )<br />
{<br />
yearsToAdd = Math.floor((month+1)/12) ;<br />
month -= 12*yearsToAdd ;<br />
yearsToAdd += numYears ;<br />
}<br />
<br />
returnDate.setMonth(month) ;<br />
returnDate.setFullYear(returnDate.getFullYear() + yearsToAdd) ;<br />
<br />
var finalDays = 0;<br />
if(numDays >= 5)<br />
{<br />
var weeks = (numDays / 5);<br />
finalDays = (weeks * 7);<br />
numDays -= (weeks * 5);<br />
}<br />
<br />
if(numDays > 0)<br />
{<br />
var dayOfWeek = returnDate.getDay();<br />
<br />
if(dayOfWeek < 4 && (dayOfWeek + numDays) >= 4)<br />
{<br />
finalDays += (numDays + 2);
}<br />
else<br />
{<br />
if(dayOfWeek == 4 || dayOfWeek == 5)<br />
{<br />
finalDays += (numDays + (5-dayOfWeek));<br />
}<br />
else<br />
finalDays += numDays;<br />
}<br />
}<br />
<br />
returnDate.setTime(returnDate.getTime()+60000*60*24*finalDays);<br />
<br />
return returnDate;<br />
}<br />
I didn't test the code, but I think it should work. Let me know if it doesn't, or if you have more questions.
[EDIT]
Sorry, slight mistake in the function if dayOfWeek = 6. Now it is fixed
[/EDIT]
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Alexander Wiseman,
Your forumula worked.
Five points for you.
Cheers ,
Regards,
The Phantom.
|
|
|
|