jquery - add a class to the body of another page by clicking on a link? -


Is it possible to use jquery so that when you click on a link, it will go to the second page and the new page Body tag

Surely the new page should open in the same window (not in the new window).

You can do this in two ways, but in both cases you have to open a new page that you First solution is

the first solution

The first solution is for example an anchor like an anchor, and in the new page in search of anchor, if it is present then you add the class $ {Document} .ready (function () {var hash = Window.location.hash.substring (1); if (hash == "hint") $ ("body" ) AddClass ("class_to_add");});

If two pages are in the same domain, then you can use cookies as a hint. You can use a library for example to add a cookie and get a cookie in another page.

  // $ .setCookie ("hint", "value") in the first page; // $ in the second page (document) .ready (function () {if cookie ("sign") == "value") $ ("body"). AddClass ("class_to_add");}); Second Solution  

The second solution is to use iframe, once you click on a link, you will see a iframe < / Code> 100% width and 100% height and then you can add the square inside the iframe page to this page outside

  $ ("Iframe"). material (). ("Body") AddClass ("class_to_add")  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -