简体   繁体   中英

Trouble understanding this javascript

I am having a hard time deciphering this javascript that I want to hopefully change to meet my needs. Can someone help me read it? I understand that the URL, including and after the hash tag, (location.hash) will be stored in the sMovie variable but I don't understand what the slice(1).replace(/\\"g,""); is doing

Thanks

<script type="text/javascript">
var sMovie=location.hash.slice(1).replace(/\"/g,"");
if (sMovie) document.write('<embed style="width:100%;height:100%" wmode="transparent" type="application/x-shockwave-flash" src="'+sMovie+'.swf">');
</script>

The slashes are the regular expression. So basically if this is your url //test.com#hello"world"

location.hash.slice(1).replace(/\"/g,"");

It will return helloworld

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM