-
using metacharacter in if statment
how to write this in javascript:
if (file == any element end with .HTML) {
do somthing
}
thanks
-
hi
Code:
<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>
*.wma
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>
-
 Originally Posted by ZABI
<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>
its working
thanks alot
-
Or with a regular expression
Code:
if (/\.HTML$/.test(file)) {
// do something if file end by .HTML
}
Slashes are the regular expression delimiters. The point must be escaped and the dollar match at the end of the string.
-
 Originally Posted by 007Julien
Or with a regular expression
Code:
if (/\.HTML$/.test(file)) {
// do something if file end by .HTML
}
Slashes are the regular expression delimiters. The point must be escaped and the dollar match at the end of the string.
Code:
<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>
another method
its working too
I have learned new things that I never knew before
thanks a lot i appreciate it
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
|
Bookmarks