0

I am learning web programming and still a dummy so please dont be harsh.

My question is I have a page where i have js

    </style>  
<script type="text/javascript">
  window.onload= function(){
   window.location = 'http://www.google.com';
  };
</script>

my question is, if there any way to modify css of the google.com page so it will look different but functionality remains?

I have no intentions doing it to google, it only for example purpose and theoretical understanding.

I was researching online but have not found anything that would work

tried this

 <iframe src="http://www.#"></iframe>  

<script>
$(document).ready(function(){
$('iframe').contents().find('#header_container').css('display', none);
</script>
Jenny
  • 445
  • 2
  • 6
  • 23
  • Nope, you can not modify look of external urls. You can do something like that but only to urls (sites) you are controling. This is done trough use of cookies (client side) or get/post variables. – Goran.it Feb 20 '14 at 16:45
  • I have access to the page. I need that whenever user accesses it straight, it displays all content, but when I use redirect it has to hide header for ex – Jenny Feb 20 '14 at 16:47
  • @Jenny if it is your page, add some code for that. You can just add a parameter on rediect like (assuming php): header("location:page.html?redirect=true"). Now you can access the **redirect** parameter on your page. Decide what to do then. – Nico O Feb 20 '14 at 16:49
  • @NicoO you actually can't do that (load in an iframe and manipulate), cross-origin policies will prevent you from manipulating a url from a different domain. Additionally, Google has a frame buster that will prevent you from iframing. – Rob M. Feb 20 '14 at 16:50
  • @Jenny what is your goal with this? Are you trying to learn something specific? – Rob M. Feb 20 '14 at 16:51
  • Oh thank you @RobM. good to know... I will remove my comment then. I should have tried it first. – Nico O Feb 20 '14 at 16:52
  • Rob, they are on the same domain, I using a cms that is very limited and I need this page look normal all the time and only when redirected from that one page it has to look modified – Jenny Feb 20 '14 at 16:54
  • The only to achieve this sort of affect would be to create a plugin that the user would have on their browser that modifies the page they are on. I remember seeing something like this with an ap called goggles or something like that. – Andrew Font Feb 20 '14 at 17:05

1 Answers1

1

I am going to go out on a limb here and guess what you are trying to do. You want to alter the look of a page on your site (not google) if you redirect to that page. If I am correct in my assumption, you should use url parameters.

On the page that redirects

<script>
  // I chose "redirect", you can use whatever name you want
  location.href = '/page2.html?redirect=1';
</script>

On the page that you are redirecting to (page2.html in this example):

<script>
  // location.search would be '?redirect=1' here, we are just checking if "redirect" is in the querystring
  var is_redirect = location.search.indexOf('redirect');

  if(is_redirect === -1) {
    // parameter was not passed, don't change the style
  } else {
    // parameter was passed, style away
    var body = document.getElementsByTagName('body')[0];
    // a couple style changes for example
    body.style.backgroundColor = '#000';
    body.style.color = '#fff';
  }
</script>
Rob M.
  • 35,491
  • 6
  • 51
  • 50
  • this is probably a wonderful solution, however even thou it's a page on mine domain, the cms does not give me access to its code. So the trick I intend to do is to override whatever they don't let me override because of source code restriction – Jenny Feb 20 '14 at 17:57
  • What CMS are you using? Do you host it on your own server or personal hosting account or is it a hosted CMS? – Rob M. Feb 20 '14 at 18:05
  • my company has cms(in house made) for hosting client web sites, hosted by cms – Jenny Feb 20 '14 at 18:12
  • Is this just for you or for other people to see as well? If you are just doing it for yourself I recommend Greasemonkey https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ or Chrome User Scripts - link to instructions installation http://userscripts.org/about/installing – Rob M. Feb 20 '14 at 18:26
  • I wish its just for myself...crazy clients want it this way...well i guess its impossible – Jenny Feb 20 '14 at 18:29
  • Not impossible, but sounds like a total pain in a$$ if you can't actually work on the code. Sorry! – Rob M. Feb 20 '14 at 18:33