Last active
September 3, 2023 10:02
-
-
Save cuongdcdev/55b7cff20ae00da38a0353e3fb27b936 to your computer and use it in GitHub Desktop.
IframeEmbedExternal.js
This file contains 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
window.addEventListener('message', function(event) { | |
console.log("test"); | |
var links = document.querySelectorAll("a"); | |
for( var i = 0; i < links.length ; i++ ){ | |
links[i].addEventListener("click" , function(e){ | |
if(event.data.iframeDisableLink){ | |
e.preventDefault(); | |
} | |
window.parent.postMessage({ | |
url: this.href | |
}, "*"); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment