I have this small iframe I would like on my site however the buttons work perect in firefox and chrome but do not show in IE or opera, I have basic coding skills so go easy please :)

Thank you.

<iframe src="caltest.html" name="myframe" width="582" height="397"
                                    align="top" scrolling="no" frameborder="1"</iframe>
                                    <br>
                                    <input type="button" value="VIP1" onclick="myframe.location.href='golfa.html'">
                                    <input type="button" value="VIP2"
                                    align="center"align="top"onclick="myframe.location.href='tennisaa.html'">
                                    <input type="button" value="VIP3"
                                    onclick="myframe.location.href='golfa.html'"src ="/default.asp"
                                    width="200" height="200" align="right">
                                    </iframe>

Dani AI

Generated

The symptom you described (works in Firefox/Chrome but not in Opera/IE) is almost always caused by two things: malformed markup and relying on a browser quirk that exposes elements as implicit globals. was on the right track by giving the iframe an id, but relying on a bare name like myframe in inline onclick code is inconsistent across browsers. Also the examples posted contain stray/invalid tags and attributes (extra closing tags, attributes on inputs that don't belong there), which will break parsing in stricter engines.

Use a clear, standards-based approach instead of implicit globals. Give the iframe an id and change its src from script using getElementById (or attach listeners to buttons) — that works consistently. A tidy, unobtrusive example:

var iframe = document.getElementById('myframe');
document.getElementById('vip1').addEventListener('click', function () {
  iframe.src = 'golfa.html';
});

If you prefer no JavaScript, links or forms can target a named browsing context directly:

<a href="golfa.html" target="myframe">VIP1</a>

Quick troubleshooting checklist: run your page through the W3C validator to catch malformed markup; open the browser console (F12) to see "undefined" or parse errors; remove deprecated attributes like align and frameborder and use CSS for sizing/centering; verify the iframe and controls are not accidentally nested inside each other. Note: scripting into the iframe (reading its document) is limited by the same-origin policy if the iframe loads a different domain.

References: MDN’s iframe documentation has current attribute and behavior notes (iframe — MDN). Use the HTML spec for details on browsing contexts (HTML living standard — iframe). Validate markup at the W3C validator (validator.w3.org).

Recommended Answers

All 2 Replies

<iframe src="test.html" id="myframe" width="582" height="397" align="top" scrolling="no" frameborder="1"></iframe><br>
<input type="button" value="VIP1" onclick="myframe.location.href='test1.html';">
<input type="button" value="VIP2" onclick="myframe.location.href='test2.html';">
<input type="button" value="VIP3" onclick="myframe.location.href='test3.html';">

Is the width height supposed to change the iframe dimesnion?

I got it thank you,

<centre><input type="button" value="VIP1" onclick="myframe.location.href='golfa.html'">
            <input type="button" value="VIP2" onclick="myframe.location.href='tennisaa.html'">
            <input type="button" value="VIP3" onclick="myframe.location.href='golfa.html'">
            <input type="button" value="VIP4" onclick="myframe.location.href='golfa.html'">
            <input type="button" value="VIP5" onclick="myframe.location.href='tennisaa.html'">
            <input type="button" value="VIP6" onclick="myframe.location.href='golfa.html'">
            <input type="button" value="VIP7" onclick="myframe.location.href='tennisaa.html'">
            <input type="button" value="VIP8" onclick="myframe.location.href='golfa.html'">
            <input type="button" value="Today's Schedule" onclick="myframe.location.href='schedule.html'">
            <width="200" height="200" align="right"></centre>
                                <br>
                                <iframe src="start.html" name="myframe" width="582" height="397"
                                                                    align="top" scrolling="no" frameborder="0"</iframe>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.