Reputation: 127
I'm trying to have working JQuery button menu which will change in attribute data, so will autoreload what's inside object parameter, but it don't want to work :(
The code with CSS, HTML and JQuery is in below link
http://jsbin.com/iqukak/2/edit
Anyone can help?
$('button#1').attr("id"){
$("object#cgi").attr('data','http://www.google.com')};
$('button#2').attr("id"){
$("object#cgi").attr('data','http://www.bing.com')};
$('button#3').attr("id"){
$("object#cgi").attr('data','http://www.yahoo.com')};
});
Update:
I have uploaded all the files to http://szary.eu/panel/
What I want to achive is:
- when I click on 1 i need 1.html inside <object>
visible
- when I click on 2 I need 2.html inside <object>
visible
Upvotes: 0
Views: 85
Reputation: 206048
$(function(){
$('td.mleft button').click(function(){
$('#cgi').attr( 'data', 'http://'+ $(this).text().toLowerCase() +'.com' );
});
});
And btw: google will never show up and for example if you point to stackoverflow you will be rerouted. So think twice what are you trying to achieve:
cause to prevent "clickjacking", they're sending a HTTP response header called "X-Frame-Options" to prevent pages to be "framed"
EDIT
I would discourage you from using <object>
tag for that purpose,
use .load()
instead:
$('#cgi').load( $(this).text() +'.html');
Upvotes: 1
Reputation: 4753
You can try this code:
$(document).ready(function(){
$('button#1').click(function() {
$("object#cgi").attr('data','http://www.google.com')});
$('button#2').click(function() {
$("object#cgi").attr('data','http://www.bing.com')});
$('button#3').click(function() {
$("object#cgi").attr('data','http://www.yahoo.com')});
});
Although I don't believe Google will let you do this anyway (Bing and Yahoo are fine though) http://jsbin.com/iqukak/15/edit
See this question for why it wont work with Google: how to open google links inside iframe?
Upvotes: 1