- For this script:
Internet Explorer get element under cursor (show borders, show text) (any zoom percentage) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=29458
- I'm trying to establish if a frame is the topmost frame.
- One method that seems to work is to check if oFrame.parent.name is blank.
- But I'm looking for something more reliable.
- If you think you have a solution, please test it before suggesting it. I've tried a lot of things. Thanks.
Links:
javascript - What is the difference between window, window.top and window.parent? - Stack Overflow
https://stackoverflow.com/questions/3473946/what-is-the-difference-between-window-window-top-and-window-parent
javascript - How to tell if current frame is parent? - Stack Overflow
https://stackoverflow.com/questions/3135380/how-to-tell-if-current-frame-is-parent
Internet Explorer: is frame topmost
Internet Explorer: is frame topmost
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Internet Explorer: is frame topmost
Window.parent === window.top?
Re: Internet Explorer: is frame topmost
I had come across that in my searches.
The thing is, how can we translate that to AHK? The ===. Thanks.
The thing is, how can we translate that to AHK? The ===. Thanks.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Internet Explorer: is frame topmost
I'm not entirely sure how perfectly this translates to AHK but if you are using Javascript, which references very similarly you can do something like this:
I used this for instance to retrieve an HTML path of an element inside of nested iframes:
Code: Select all
var parent = element.parentElement; //gets the parentElement
if(parent === null){ //if the parent element is null it is either HTML or we are at the top of an iframe/frame.
if (element.ownerDocument !== document){
// This means that the elements ownerdocument is not the html root doc so it must be a contentDocument of a nested frame of
//some sort and you can use something like below to get out of the iframe and up the tree to the actual iframe element
parent = element.ownerDocument.defaultView.frameElement;
}
if (element.ownerDocument == document){
// This means that the elements ownerdocument is the html root doc.
}
}
Code: Select all
function pathOfElement(element){
var parent = element.parentElement;
var elementString;
var parentElementPath;
var standardTags = ["A","ABBR","ACRONYM","ADDRESS","APPLET","AREA","ARTICLE","ASIDE","AUDIO","B","BASE","BASEFONT","BDI","BDO","BIG","BLOCKQUOTE","BODY","BR","BUTTON","CANVAS","CAPTION","CENTER","CITE","CODE","COL","COLGROUP","DATA","DATALIST","DD","DEL","DETAILS","DFN","DIALOG","DIR","DIV","DL","DT","EM","EMBED","FIELDSET","FIGCAPTION","FIGURE","FONT","FOOTER","FORM","FRAME","FRAMESET","H1","H2","H3","H4","H5","H6","HEAD","HEADER","HR","HTML","I","IFRAME","IMG","INPUT","INS","KBD","LABEL","LEGEND","LI","LINK","MAP","MARK","META","METER","NAV","NOSCRIPT","OBJECT","OL","OPTGROUP","OPTION","OUTPUT","P","PARAM","PICTURE","PRE","PROGRESS","Q","RP","RT","RUBY","S","SAMP","SCRIPT","SECTION","SELECT","SMALL","SOURCE","SPAN","STRONG","STYLE","SUB","SUMMARY","SUB","SVG","TABLE","TBODY","TD","TEMPLATE","TEXTAREA","TFOOT","TH","THEAD","TIME","TITLE","TR","TRACK","U","UL","VAR","VIDEO","WBR"];
// no parents mean we reached the top of the Document
if(parent === null){
if (element.ownerDocument !== document){
parent = element.ownerDocument.defaultView.frameElement;
elementString = "HTML";
parentElementPath = "";
parentElementPath = pathOfElement(parent);
}
if (element.ownerDocument == document){
elementString = "HTML";
parentElementPath = "";
}
} else {
// turn HTMLCollection object into an array
// using Array.prototype.slice.call
var parentsChildren = Array.prototype.slice.call(parent.children);
// remove children that don't match our tag, they don't matter here
parentsChildren = parentsChildren.filter(function(child) { return child.nodeName.toLowerCase() == element.nodeName.toLowerCase();} );
// if this tag name is unique, we don't need a position number
if(parentsChildren.length == 1){
elementString = element.nodeName;
if(standardTags.indexOf(elementString)==(-1)){
elementString = elementString.toLowerCase();
}
} else {
var elementPosition = parentsChildren.indexOf(element) + 1;
if(standardTags.indexOf(element.nodeName)==(-1)){
elementString = element.nodeName.toLowerCase() + "(" + elementPosition + ")";
} else {
elementString = element.nodeName + "(" + elementPosition + ")";
}
}
// recurse up the DOM, getting our ancestor Paths
parentElementPath = pathOfElement(parent);
}
return parentElementPath + "/" + elementString;
}
Re: Internet Explorer: is frame topmost
Getting frame number have previously been implemented in iWB2 learner,
You can find hint from iWB2 learner,
https://autohotkey.com/board/topic/84258-iwb2-learner-iwebbrowser2/
https://github.com/AshetynW/iWB2-Learner/blob/master/iWB2%20Learner
if web page does not have any frame, then frame detail remains empty,
You can find hint from iWB2 learner,
https://autohotkey.com/board/topic/84258-iwb2-learner-iwebbrowser2/
https://github.com/AshetynW/iWB2-Learner/blob/master/iWB2%20Learner
if web page does not have any frame, then frame detail remains empty,
Code: Select all
if pelt := pwin.document.elementFromPoint( xpos-xorg:=pwin.screenLeft, ypos-yorg:=pwin.screenTop ) {
Stored.LV := object() ; hold frame info for ListView
while (type:=pelt.tagName)="IFRAME" || type="FRAME" {
selt .= A_Index ") **[sourceIndex]=" pelt.sourceindex " **[Name]= " pelt.name " **[ID]= " pelt.id "`n"
, Stored.LV[A_Index, "C1"] := type "." A_Index
, Stored.LV[A_Index, "C2"] := pelt.sourceindex
, Stored.LV[A_Index, "C3"] := pelt.name
, Stored.LV[A_Index, "C4"] := pelt.id
, Frame[A_Index] := pelt ; store frames
, pwin := Query_Service(pbrt:=pelt.contentWindow, IID_IHTMLWindow2)
, pdoc := pwin.document
, Stored.LV[A_Index, "URL"] := pdoc.url
, pbrt := pdoc.elementFromPoint( xpos-xorg+=pelt.getBoundingClientRect().left
, ypos-yorg+=pelt.getBoundingClientRect().top )
, pelt := pbrt
}
; *********************
if selt ; if the element is in a frame, get frame dimensions
Frect := Frame[Frame.maxIndex()].getBoundingClientRect() ; get the Frame Rectangle
, Frame.x1 := xorg ; set the frame Coordinates
, Frame.y1 := yorg
, Frame.x2 := FRect.right+xorg
, Frame.y2 := FRect.bottom+yorg
else,
Frame.x1:=Frame.y1:=Frame.x2:=Frame.y2:= "NA" ; if there isn't any frames, assign frame coords "NA"
- Attachments
-
- frame.PNG (29.96 KiB) Viewed 73 times
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
Re: Internet Explorer: is frame topmost
Does that work with nested frames?
Who is online
Users browsing this forum: 20170201225639, Bing [Bot], Fumetsu, jackn11, kczx3, mikeyww and 39 guests