I was wondering to do trough javascript a check if the src of an iframe is the same as the href of the given link so that if they are equal to set the class to current
Of course I don't really know Javascript this well but it would be great
<script>
changeclass() {
var iframesrc = document.getElementById("videobox").contentWindow.location.href
if(iframesrc=###a.href###) {
var linknumber = ###a.href;
document.getElementById("linknumber").className = "current";
}
}
</script>
<a name="link1" href="samelink" class="current">Video 1</a>
<a name="link2" href="different link" class="">Video 2</a>
<a name="link3" href="different link" class="">Video 3</a>
<iframe name="videobox" src="samelink">
Thanks, Im sorry for not having the smallest idea of how to do javascript into my code.
Is this what you are expecting:
HTML:
<a name="link1" href="samelink" class="current">Video 1</a>
<a name="link2" href="different link" class="">Video 2</a>
<a name="link3" href="different link" class="">Video 3</a>
<iframe id="videobox" name="videobox" src="samelink">
JS:
var iframesrc = document.getElementById("videobox");
var ahref = document.querySelectorAll("a");
var iframePath = iframesrc.getAttribute("src");
for(var i=0;i<ahref.length;i++){
var fhref = ahref[i].getAttribute("href");
if(iframePath == fhref){
var classActive = ahref[i].className = "activeLink";
console.log(classActive);
}
}