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!