Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 206

window.opener.returnValue in Chrome with showModalDialog

$
0
0

I am trying to use window.opener.returnValue with showModalDialog. There are numerous references to a technique which can be used to workaround window.returnValue not working. However it just doesn’t seem to work in Version 23.0.1271.97 of Chrome.

If I comment out the self.close line as follows, and put alerts in before and after the return value is set then both alerts show as ‘undefined’:

The caller a1.html

<html><head><base target="_self"/><script>  function fu()  {    window.returnValue = undefined;    var result = window.showModalDialog("b1.html", window, "dialogHeight:650px; dialogWidth:900px;");    if (result == undefined)        result = window.returnValue;    if (result != null && result != "undefined")        text.value = result;  }</script></head><body><input type=button value="click me" onclick="return fu();"><input type=text id=text></body></html>

The called b1.html:

<html><head><base target="_self"/><script>  function fu()  {   var text = document.getElementById("text");  if (window.opener)  {    alert(window.opener.returnValue);    window.opener.returnValue = "your return value";    alert(window.opener.returnValue);  }  text.value = window.opener.returnValue;  //self.close();  }</script></head><body><input type=button value="close" onclick="return fu();"><input type=text id=text></body></html>

Viewing all articles
Browse latest Browse all 206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>