-
Aug 8th, 2013, 09:52 AM
#1
Thread Starter
Member
[Javascript] Loading data based on URL?
I have an Enjin website and they allow near unlimited pages, but only 50 modules to work with. One of the modules I can use is an HTML module that accepts only HTML & Javascript. One of my pages list all of our live Twitch streamers and displays all their streams on one page. http://greatartchitect.enjin.com/live or http://greatarchitect.us/live
What I wanted to do is create a new page for every streamer using only 1 HTML module and load a stream based on the page URL. The only way I know to do this is for javascript to look for the page URL and then load a specified stream based on which page the HTML module is being loaded from.
Now I don't have any problem loading the streams what I need help with is an If..Then or Case Statement in javascript. I have done some research and it may be a Switch statement that I need. I don't know enough about javascript to write this properly. I feel like this should be pretty simple. Could someone please help me out with this?
Thank you,
SeeingBlue
-
Aug 8th, 2013, 06:37 PM
#2
Re: [Javascript] Loading data based on URL?
-
Aug 9th, 2013, 03:10 PM
#3
Thread Starter
Member
Re: [Javascript] Loading data based on URL?
Thanks for your help..
This is what I have wrote so far but it doesn't work. How should it look?
Code:
<script language="text/javascript">
var URL = document.URL;
<--switch (URL) {
case "http://www.greatarchitect.us/defatank":
document.write("Displaying Defatank");
break;
case "seeingblue":
document.write("Displaying SeeingBlue");
break;
case "shiroshii":
document.write("");
break;
case "theend66":
document.write("");
break;
case "wakawaka647":
document.write("");
break;
case "xtheguythatplays":
document.write("");
break;
}-->
</script>
Last edited by SeeingBlue; Aug 9th, 2013 at 03:45 PM.
-
Aug 9th, 2013, 08:23 PM
#4
Re: [Javascript] Loading data based on URL?
- Why do you have <-- and --> in there?
- <script language="text/javascript"> should be <script type="text/javascript">
- Your URLs are inconsistent; look at what the value of document.URL actually is, do some debugging. (Then drop that and use window.location.pathname instead.)
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
|
Click Here to Expand Forum to Full Width
|