-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame.js
54 lines (48 loc) · 1.38 KB
/
frame.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function CreateFrame(windowRef) {
if (windowRef) {
this.frame = windowRef.document.createElement("iframe");
return;
}
this.frame = document.createElement("iframe");
}
CreateFrame.prototype.set = function (attr, val) {
this.frame[attr] = val;
return this;
};
CreateFrame.prototype.setStyle = function (styleObj) {
var attr;
for (attr in styleObj) {
if (styleObj.hasOwnProperty(attr)) {
this.frame.style[attr] = styleObj[attr];
}
}
return this;
};
CreateFrame.prototype.overrideStyle = function (style) {
this.frame.style.cssText = style;
return this;
};
CreateFrame.prototype.done = function () {
return this.frame;
};
function createAndAttachIFrame() {
var iFrameElement = new CreateFrame()
.set('id', 'testFrame')
.set('marginWidth', 0)
.set('marginHeight', 0)
.set('scrolling', 'no')
.set('frameBorder', 0)
.set('height', 250)
.set('width', 300)
.set('style', "margin: 20%;")
.done();
var frame;
var documentBody = document.getElementById("wrapper-box");
if (documentBody.firstChild) {
frame = documentBody.insertBefore(iFrameElement, documentBody.firstChild)
} else {
frame = documentBody.appendChild(iFrameElement);
}
return frame;
}
window.createAndAttachIFrame = createAndAttachIFrame;