I have a parent page containing two iframes. One holds navigation links and the other should display the information pertaining to the navigation link clicked in the first iframe. So I need to target the one iframe from within another iframe.Is this possible? If so how does one go about it?
I figured it out. For those who want to know, you need to use javascript to access the parent document elements and change the attributes. So to answer my own question, one sets the onclick link to run the following javascript:
parent.document.getElementById('frameName').src = 'page.html';
Related
I've been searching and searching and for some reason I cannot figure this out as simple as it probably is.
I am trying to link a logo from a list on a home page and connect it to the full details related to it on a separate page. The full details on the separate page are in a carousel being controlled by data targets, How can I link the logo from the home page to the specific data target on the full details page?
The best method would be to add a hash for the anchor tag to your url, and then use javascript to read the hash and then scroll to it! Here's a duplicate question with an answer that successfully accomplishes the effect jQuery scroll to ID from different page
If I understand the question, assuming the logo is displayed in an <img> tag, try wrapping an anchor tag around it with an href like so
<img src"myImg.jpg>
I have a page with multiple iframes, at a time one one iframe is active, and i would like to know which iframe is active currently.
I tried document.activeElement.id, but it gives correct result only when I click on page some where.
I tried this also but not giving me active iframe id.
Do you know any javascript/jquery api to know active iframe id.
Using jQuery you can try this:
var $focused = $(':focus');
The above will get the element that currently has focus.
I have a iframe that opens different page depending upon the items selected in a menu. Each page in a iframe contains div elements and tables.
My requirement is to set focus on the first div or table in a iframe. Therefore I am looking for a way to access id of first div or first table and set focus on it.
Since pages loaded in a iframe are depended upon the menu items selected, I couldnot use getElementById method to access elements inside iframe.
I have tried to access first div element in a iframe using following code :
var innerElement = iframeObject.contentWindow.document.getElementsbyTagName('div')[0];
innerElement.focus();
But , innerElement is regarded as undefined.
However I was able to set focus on iframe using :
iframeObject.contentWindow.focus();
but could not set focus on inner div.
Can anyone help, how could i access the first elements of a iframe?
If you're trying to reach out a specific HTML element from an external source (URL out of your domain), you can't do that forsake of DOM security reasons!!
I have added my visualforce page to Account page and found that I can set only fixed height. I wrote javascript solution for auto height. First part I added to the parentAccount page by adding new button with {!REQUIRESCRIPT("my_scipt_here")}, second part I added to visualforce page.
s it possible to add javascipt to the "parent" Account page without adding Custom Button?
I'm not aware of any way to run javascript on a page other than by using a button (or maybe a link as a field), though it'd be good to know if there is one but I highly doubt it would be available, or if it is, supported.
Would overriding the Account view page with a full visualforce page be an option where you use an <apex:detail> tag to get the standard fields etc.?
Remember that Visualforce components on page layouts occur as iframes. If the domains match up, which may or may not be the case - you could inject JavaScript from the iframe to the parent.
This may give more details:
Inject javascript function into parent window from iframe
I want to link to a page which contains multiple support topics.
When the user clicks on the link while being on an external site, the topic should be expanded as soon as the user arrives on the support page.
Example:
I link to this page
http://www.nintendo.de/NOE/de_DE/support/nintendo_ds_lite_159_142.html
Topic I want to be opened on arrival
javascript:fadeNAppearDiv('box_3_9277');
(First topic in the FAQs)
It's not clear if you are maintaining the target site (where the div will open) or not. If you don't have access to the code for that page, then there isn't any way to invoke the javascript function on it. If you can modify that page, you can do as #PhiLho suggests and modify the URL you are using to specify the DIV to open and have an onLoad handler that parses the URL and opens the appropriate DIV.
Good idea, but I don't see the question... :-)
The way I saw on some sites, like deviantART, is to use the sharp anchor notation: myURL.com/foo/page.html#TopicToExpand
JS can analyze the current URL and get the anchor part, then do whatever you need to do to highlight/jump to the right place.