0

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

Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313
Sebastian Szary
  • 127
  • 2
  • 10

2 Answers2

1

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?

Community
  • 1
  • 1
Beno
  • 4,633
  • 1
  • 27
  • 26
  • i've tried your link and it works for Bing and Yahoo. Google will not work - they won't allow it – Beno Nov 25 '12 at 23:15
  • Hm, I've tried that in Google Chrome @ Windows and it wasn't working, but under Firefox @ Linux it's working ... – Sebastian Szary Nov 25 '12 at 23:42
  • 1
    Check out http://stackoverflow.com/questions/4324108/unsafe-javascript-attempt-to-access-frame-with-url Chrome itself is blocking the request because it views it as being unsafe – Beno Nov 25 '12 at 23:54
  • do You know how I can achieve what I want in google chrome? Because it's starting to be a little frustrating that I can't embed a html site (or rather cgi script will be the destination) inside my html site :-/ @Beno – Sebastian Szary Nov 26 '12 at 00:12
  • @SebastianSzary you can try use an iframe instead. see here: http://jsbin.com/iqukak/20/edit – Beno Nov 26 '12 at 00:20
1
$(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');
Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313