how to write this in javascript:
if (file == any element end with .HTML) {
do somthing
}
thanks
Printable View
how to write this in javascript:
if (file == any element end with .HTML) {
do somthing
}
thanks
hi
*.wmaCode:<script type=text/javascript>
var dd = ["a.mp3","b.wav","c.flv","d.wma",.....];
for (i=0;i<4;i++) {
if (dd[i] == *.wma) {
document.write(" WMA ");
}
}
</script>
or
$wma >>>> any element end with wma
its possible to do this in javascript?
<script type=text/javascript>
var dd = ["a.mp3","b.wav","c.flv","d.wma"];
for (i=0;i<4;i++) {
var ext=dd[i].substring(dd[i].lastIndexOf('.')+1,dd[i].length);
if (ext == 'wma') {
document.write(" WMA ");
}
}
</script>
Or with a regular expression
Slashes are the regular expression delimiters. The point must be escaped and the dollar match at the end of the string.Code:if (/\.HTML$/.test(file)) {
// do something if file end by .HTML
}
another methodCode:<script type=text/javascript>
var dd = ["a.mp3","b.wav","f.html","d.wma","c.flv"];
for (i=0;i<5;i++) {
if (/\.html$/.test(dd[i])) {
document.write(" HTML "); // <iframe ....>
}
}
</script>
its working too
I have learned new things that I never knew before
thanks a lot i appreciate it