Home > Web Front-end > JS Tutorial > body text

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

Susan Sarandon
Release: 2024-10-20 19:23:02
Original
520 people have browsed it

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>
Copy after login

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

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

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!

source:php
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!