0

Not sure if this can be done but I'm trying to redirect a url to a certain div. To give you more details of what I want to achieve is I have 1 page with 2 tabs and different url, I replaced that page with just 1 page and instead of 2 tabs I have the content just under each other. I few 3rd party websites link to these tabs so instead of sending the new url to them I was wondering if I can use those url's in the divs and when the user goes to the urls it redirect straight to that div.

In html you can do this

<a href="#div1">Div 1</a>
<div id="div1">Loremipsum........</div>

and i want to do this

<a href="#div1">Div 1</a>
<div id="div1 & http://www.gogle.com/div1">Loremipsum........</div>

Can it be done? I cannot find any documentation or examples.

Thanks

Joseph Zammit
  • 381
  • 2
  • 12
  • no there is no way in html/css to do that. If you want to redirect you would need to add JavaScript code to read the url and set the hash or scroll to the element – epascarello Oct 13 '16 at 02:46
  • ...iframe?.. what i would do.. – james walker Oct 13 '16 at 02:54
  • ofcource you can http://jsfiddle.net/YYPKM/3/ --- http://stackoverflow.com/questions/25020582/scrolling-to-an-anchor-using-transition-css3 – Tasos Oct 13 '16 at 02:55
  • Yes I know that can be done but what i want to achieve is something like this updated fiddle http://jsfiddle.net/YYPKM/2480/ – Joseph Zammit Oct 13 '16 at 02:55
  • No you cant do it that way i saw your question differently. You are out of luck. but javascript is inbuilt in the browsers so use that – Tasos Oct 13 '16 at 03:03
  • JavaScript is an answer, or (imo better yet) if you have access to this, add an apache/nginx redirect (301 of course) to your URL with correct hash. – Amelie Turgeon Oct 13 '16 at 03:33
  • I third party website needs to provide a way for the specific content you want to be linked to, investigate to see if the website already does this, ie it might use #content at the end of a url, or might have sub urls that refer to elements on a page, this is uncommon unless its user created content, SO has a system like this if you click share on an answer – Jim Jones Oct 13 '16 at 03:54
  • If the site does not provide ang mechanism for this, link as close to the content as you can, and perhaps provide some direction near the link (ie click and scroll down a bit) – Jim Jones Oct 13 '16 at 03:56
  • Don't use iframes or any other method that will give you control over how the other site is displayed, you'll have to jump over several security hurdles and final product won't be fully what you want – Jim Jones Oct 13 '16 at 03:57

1 Answers1

0

Hmmm I dont see your problem... When you go to a page like www.example.com/index.foo#something (note the #something in the end - stackoverflow is reformating when i want to write it bold beacuse of the #) you will actually to the jump where the id "something" is placed. Try it out:

https://jsfiddle.net/8btkp706/

<a href="#something">Something</a>
<div id="something">
    Soooooooooooo down below....
</a>
KoalaGangsta
  • 397
  • 1
  • 17