URL detection with JavaScript
- by josh
Hi! I'm using the following script to force a specific page - when loaded for the first time - into a (third-party) iFrame.
<script type="text/javascript">
if(window.top==window) {
location.reload()
} else {
}
</script>
(For clarification: This 'embedding' is done automatically by the third-party system but only if the page is refreshed once - for styling and some other reasons I want it there from the beginning.)
Right now, I'm wondering if this script could be enhanced in ways that it's able to detect the current URL of its 'parent' document to trigger a specific action? Let's say the URL of the third-party site is 'http://cgi.site.com/hp/...' and the URL of the iFrame 'http://co.siteeps.com/hp/...'. Is it possible to realize sth. like this with JS:
<script type="text/javascript">
if(URL is 'http://cgi.site.com/hp/...') {
location.reload()
}
if(URL is 'http://co.siteeps.com/hp/...') {
location.do-not.reload() resp. location.do-nothing()
}
</script>
TIA josh