Created
August 31, 2013 13:47
-
-
Save IanCal/6398286 to your computer and use it in GitHub Desktop.
A simple inclusion approach
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<head> | |
</head> | |
<body> | |
<section name="anchor1"> | |
I am the INCLUDED THING | |
<section name="anchorsub"> | |
I am a teeny tiny inclusion | |
</section> | |
</section> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<head> | |
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<section> | |
I am a main section | |
<section> | |
I am a subsection, with external links | |
<div><a href="includethis.html#anchor1" load="external">link 1</a></div> | |
<div><a href="includethis.html#anchorsub" load="external">link 2</a></div> | |
</section> | |
</section> | |
<script> | |
$("[load*='external']").each(function(i, _elem) { | |
var elem = $(_elem); | |
var linkurl = elem.attr("href").split("#"); | |
var loc = linkurl[0]; | |
var anchor = linkurl[1]; | |
var url = loc + " [name*='" + anchor + "']"; | |
elem.parent().load(url); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment