Home  >  Article  >  Web Front-end  >  How to Resolve IFrame Source Change Failure in JavaScript Due to Obsolete Event Handler?

How to Resolve IFrame Source Change Failure in JavaScript Due to Obsolete Event Handler?

Susan Sarandon
Susan SarandonOriginal
2024-10-20 19:23:02528browse

How to Resolve IFrame Source Change Failure in JavaScript Due to Obsolete Event Handler?

Changing iFrame Source with JavaScript

When you encounter difficulties changing the source of an iFrame using JavaScript, as in the provided code snippet, it's crucial to examine the event handler for radio button selection. In this specific instance, the code uses the obsolete onselect event handler, which is no longer supported in modern browsers.

To resolve this issue, replace onselect with onclick:

<code class="html"><input name="calendarSelection" type="radio" onclick="go('...')" /></code>

Additionally, the brackets within the getElementById function should be changed from ['calendar'] to ('calendar').

<code class="js">document.getElementById('calendar').src = loc;</code>

With these adjustments, the code should function as intended, allowing you to update the iFrame's source when a radio button is clicked.

The above is the detailed content of How to Resolve IFrame Source Change Failure in JavaScript Due to Obsolete Event Handler?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn