IE href = "javascript: customFunction ()" does not work when loading the first frame

I have a custom date picker that sometimes doesn't work in IE. It works great in Chrome and Edge.

The code looks something like this:

<frameset> <frame>Buttons for next/prev month/year</frame> <frame>This is the actual calendar that gets redrawn when the above buttons are used <a href="javascript:parent.opener.setDate(1);">1</a> //there a different anchor tag for each day of the month </frame> <frameset> 

So here, where it looks weird. We have two networks, call them old and new. The old probably has a lot of undocumented changes in global politics, and the new is probably close to the gov standard. This works in any browser on the old network, but not in IE (11) on the new network. However, it works in Edge. In addition, if the buttons of the upper frame are used to select the next / previous month or just the Today button, then all the links of the lower frame anchor work fine. There are no console errors / warnings, nothing in the network monitor, showing that the request returned an error code, clicks are simply not logged. I set a breakpoint inside customFunction () and it will not break when the links do not work, but it will break if the link works.

The only thing that seems strange to me is that the code for the popup looks something like this:

 str = "<frameset><frame name='topFrame' " + "src='javascript:parent.opener.drawTop'></frame><frame name='bottomFrame' "+ "src='javascript:parent.opener.drawBottom'><frame</frameset>" document.write(str); 

I looked to check, and the code that redraws the bottom frame when using the prev / next / etc buttons is the same function that gets called during the first boot.

However, what is strange is that at the first boot, the DOM inspector shows everything (top frame, bottom frame, including all individual numbers for each day of the month, etc.), but the debugger (F12 tools) doesnโ€™t show the code, loaded from document.write (str); line. To see this code and set breakpoints, I have to use the prev / next buttons, and then an additional .html file appears in Debugger, which has built HTML that corresponds to the DOM.

+7
javascript internet-explorer frameset
source share
3 answers

try the following:

one)

 <a href="javascript:parent.opener.setDate(1); void(0);">1</a> 

2)

 <a href="javascript:function(){parent.opener.setDate(1); return false;}">1</a> 

3)

 <a href="#" onclick="javascript:parent.opener.setDate(1); return false;">1</a> 

4) check your code. Your frame may have a sandbox attribute. This attribute may block javascript. Example:

  <iframe src="URL" sandbox> 
+4
source share

In addition to Nutscracker's great suggestions, I also had my share of undefined issues with document.write and event handlers that are not related to IE. The issue commented by ConnorsFan might be the reason here, but you can also try:

 document.body.innerHTML = '<frameset><frame name="topFrame" ' + 'src="javascript:parent.opener.drawTop"></frame><frame name="bottomFrame" '+ 'src="javascript:parent.opener.drawBottom"><frame></frameset>' 

You can also check if this code is actually called, maybe the real working popup is loaded from another location using the prev / next buttons, and these are just some of the remaining things.

+3
source share

If the onclick function returns false, the default browser behavior is canceled. Thus:

 <a href='http://www.google.com' onclick='return check()'>check</a> <script type='text/javascript'> function check() { return false; } 

This means that you can configure your JavaScript function as an onclick event and simply attach the anchor tag to the page you are on - since it will not redirect you when you click on it, but this requires the href attribute.

0
source share

All Articles