What I have below is a script that passes a variable from the crossvalue.html to an iframe crossvaluePOST.html and creates a localstorage to the (without www) domain.com
My question is how can I create the same localstorage value for the www.domain.com when domain.com/crossvalue.html (without www) runs?
this is crossvalue.html
<iframe id="da-iframe" src="crossvaluePOST.html"></iframe>
<script>
window.onload = function () {
var iframeWin = document.getElementById("da-iframe").contentWindow;
myMessage= Math.floor(Math.random()*801);
iframeWin.postMessage(myMessage, "http://domain.com");
return false;
};
</script>
and this is the crossvaluePOST.html
<script>
function displayMessage (evt) {
var message;
if (evt.origin !== "http://domain.com") {
message = "You are not worthy";
}
else {
localStorage['abc'] = evt.data;
}
}
if (window.addEventListener) {
// For standards-compliant web browsers
window.addEventListener("message", displayMessage, false);
}
else {
window.attachEvent("onmessage", displayMessage);
}
</script>