PageSourceSearch

https://www.madmonkeyapparel.ca/js/IFrameUtils.js?20150930

js madmonkeyapparel.ca collected 2026-09-30 12:32:43 UTC 3,311 bytes, 106 lines download raw bytes

1// This script handles messages from iframe sub-windows to scroll the main page to a certain anchor
2// For example, showrooms and presentations do this to scroll to the top of categories
3
4// Common utility functions:
5
6function findYPos(obj){
7	var posY = obj.offsetTop;
8	while(obj.offsetParent){
9		if(obj==document.getElementsByTagName('body')[0]){break}
10		else{
11			posY=posY+obj.offsetParent.offsetTop;
12			obj=obj.offsetParent;
13		}
14	}
15	return posY;
16}
17function GetFrameHeight()
18{
19	var height;
20	if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Chrome")!=-1) {
21		height = document.body.offsetHeight+40;
22	}
23	else {
24		height = document.body.scrollHeight+40;
25	}
26	return(height);
27}
28function resizeIframe( framename, height ) { 
29	var iframe = top.document.getElementById( framename ); 
30	iframe.setAttribute( "height", height );
31}
32
33// This is for the parent page:
34
35window.addEventListener("message", receiveMessage, false);
36function receiveMessage(event)
37{
38	// If we want to check to make sure the poster is authorized, use
39	// event.origin and check to make sure it matches the domain name of this site
40	// (but for now using wildcard *)
41	// event.data format is WE01-12345  where WE01 is the MsgID and everything after the dash is the data for the message
42	if (typeof event.data!='string') return;
43	var MsgID=event.data.substring(0,4);	
44	var Data=event.data.substring(5);
45	if (MsgID=="WE01") {		// Iframe Resizer
46		var IFrameSize=parseInt(Data);
47		scrollTo(0,0);
48		resizeIframe("WE_Frame",IFrameSize);
49	}
50	else if (MsgID=="WE02") {	// Iframe scroll to position
51		var iframePos=findYPos(parent.document.getElementById('WE_Frame'));
52		var AnchorPos=parseInt(Data);
53		top.window.scrollTo(0,iframePos+AnchorPos);
54	}
55	else if (MsgID=="WE03") { 	// Scroll the parent to the top
56		scrollTo(0,0);
57	}
58	else if (MsgID=="WE04") {	// Launch VDS
59		document.getElementById('VDSAnchor').href=Data;
60		document.getElementById('VDSAnchor').click();
61	}
62}	
63
64// This is for the iframe page:
65
66function ResizeIFrameWhenDoneLoading()
67{
68	if (self.name=='WE_Frame') {
69		window.onload = function() { TellParentToResizeIFrame(); }
70	}	
71}
72function TellParentToResizeIFrame()
73{
74	var FrameHeight=GetFrameHeight();
75	window.parent.postMessage("WE01-"+FrameHeight,"*");
76}
77function MoveTo(toanchor) 
78{
79	if (toanchor>"") {
80		if (window.name=='WE_Frame') {
81			// If we're in WE/WEP, tell the parent window how far down we need to go in the iframe 
82			// and the parent window will move the parent down to the right spot.  This is to 
83			// get around an issue in FF and Chrome where it will not move a page in an iframe without
84			// a scrollbar.  And we cannot move the parent directly due to same origin security issues.
85			anchorPos=findYPos(document.getElementById(toanchor));
86			window.parent.postMessage("WE02-"+anchorPos,"*");
87		}
88		else {
89			// If not in the WE_Frame, just use the normal method to support when embedded in other frames
90			location="#"+toanchor;
91		}
92	}
93}
94function SelectListMoveTo(selectlist) 
95{
96	var toanchor=selectlist.options[selectlist.selectedIndex].value;
97	MoveTo(toanchor);
98}
99function ScrollToTop()
100{
101	MoveTo('0');
102}
103function ScrollParentToTop()
104{
105	window.parent.postMessage("WE03","*");
106}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.