# Simple JavaScript function help

**URL:** https://forum.kirupa.com/t/simple-javascript-function-help/171128
**Category:** web dev
**Created:** [December 2, 2005, 1:59am UTC](https://forum.kirupa.com/t/simple-javascript-function-help/171128 "2005-12-02T01:59:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![PCGamre](https://avatars.discourse-cdn.com/v4/letter/p/ea666f/32.png) [@PCGamre](https://forum.kirupa.com/u/PCGamre)
#### Post date: [December 2, 2005, 1:59am UTC](https://forum.kirupa.com/t/simple-javascript-function-help/171128/1 "2005-12-02T01:59:50Z")

</div>

Tired of trying to figure this out. I have a flash menu. All I want to do is if the “Home” link is pressed it only loads homepage (let’s say “index.html”) if user is not already at index.html. My js is lame :(.

```auto
<script language="JavaScript">
	function homePage() {
		var url = "index.html";
		if (document.location.href == url) {
			window.location.href = 'index.html';
		}
	}
			
</script>

```

Yeah, I have this on the btn in the flash file:

```auto
on (press) {
	getURL("javascript:homePage()");
}

```
