A.html
<div class="X"></div>
<div class="Y"></div>
B.html
<iframe scrolling="no" src="A.html">
When user visits A.html set div Y to display: none
When user visits B.html set div X to display: none
A.html
<div class="X"></div>
<div class="Y"></div>
B.html
<iframe scrolling="no" src="A.html">
When user visits A.html set div Y to display: none
When user visits B.html set div X to display: none
Just Use this script in A.html i hope u'll get your desire result !
<script type="text/javascript">
$(document).ready(function () {
var path = window.location.pathname;
var ref = document.referrer;
if (path == '/A.html' && ref!='')
{
$('[class="Y"]').css('display', 'none');
}
else {
$('[class="X"]').css('display', 'none');
}
});
</script>
Someone posted the answer and it worked. But for some reason, the original answer was deleted.
$(document).ready(function () {
var path = window.location.href;
if(path=='http://www.example.com/A.html')
{
$('[class="Y"]').css('display', 'none');
}
else {
$('[class="X"]').css('display', 'none');
}
});
you just need to add name property in your iframe ex.
< iframe scrolling="no" src="A.html" name="Ahtml" >
then access using window.document.Ahtml.document (iframe has different document object)