I'm looking to make a page that loads in data from various divs on a separate page depending on the hash part of the url.
If a page is loaded with the url of
www.example.com/#about
this will load info from an external
page
(
what-cms.php
) where the div has an id of #about
Below is how I think it might look, but I can not get it to work. Does anyone know a solution?
Also, can I put the
hash
variable in the
.load
() event to act as the div to load from the what-cms.php page?
- <body>
- <script type="text/javascript">
- $(window).load (function() {
- var hash = new String(window.location.hash);
- if ("hash:contains('#')")
- {
- $('#stuff').load('what-cms.php hash');
- alert("you loaded" + hash);
- }
- else {
- $('#stuff').load('what-cms.php #home');
- alert("Nothing to load");
- }});
- </script>
- <div id="stuff">Loading...</div>
- </body>