ristenk1
ristenk1

Reputation: 433

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>

Upvotes: -1

Views: 73

Answers (1)

Alex Shilman
Alex Shilman

Reputation: 1547

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

Upvotes: 1

Related Questions