Jump to content

How to return focus to parent page from child page with an anchor?


benphp

Recommended Posts

I've been pulling my hair out with this one.

 

I have a page with an iframe with an anchor.

 

Main frame - myTasksIframe.php

<iframe src="myTasksIframe.php?PID=1234&testPID=5678#iframeAnchor=$iframeAnchor">

 

When I click on a link in the iframe:

 

Iframe = myTasksIframe.php

<a href="myTask.php?testPID=$testPID&iframeAnchor\" target=\"_parent\">Go to place in iframe</a>

 

it will refresh the main page, and skip down to the anchor in the iframe.

 

Trouble is that the page focus goes to the iframe, and the page is shifted down and I can't figure out how to make the anchor happen while setting the main page to NOT focus on the iframe and shift the page down.

 

I've tried many versions of

 

window.scrollTo(0,0);
parent.window.scrollTo(0,0);
opener.window.scrollTo(0,0);
opener.scrollTo(0,0);
parent.window.location = "#"

 

and so on. I can't get any of it to work. Please HELP!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.