-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchildframe.html
76 lines (76 loc) · 3.3 KB
/
childframe.html
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>dev.iframe.com</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
</head>
<body style="padding: 2rem 0.25rem; background: #efefef;">
<div class="container">
<div class="row">
<div class="col">
<h1 style="font-size: 1.60rem; margin-bottom: 1.5rem;">child frame invinciblecreative.com</h1>
<form name="user_data">
<div class="form-group">
<label for="user_age">Age</label>
<input type="number" name="user_age" class="form-control" id="user_age" min="1" aria-describedby="user_age" required>
</div>
<div class="form-group">
<label for="user_height">Height</label>
<input type="number" name="user_height" class="form-control" id="user_height" aria-describedby="user_height" required>
</div>
<button class="btn btn-lg btn-success float-right" type="submit">Send</button>
</form>
</div>
</div>
</div>
<script type="text/javascript">
// Using the form's submit button, let's submit the form using
// JavaScript and jQuery.
$("form[name='user_data']").submit(function(e) {
// Prevent the form from submitting via its default manner.
e.preventDefault();
e.stopPropagation();
// Send the user's age and height to the parent window--sending the
// data as an object that the parent can receive and parse.
const domain = 'https://vinniejames.de';
console.log("Sending data to ", domain);
parent.postMessage(
{
user_age: $("input[name='user_age']").val(),
user_height: $("input[name='user_height']").val(),
},
domain);
// The `parent.postMesage()` call allows you to specify "*" as the
// second argument--allowing you to send messages to any parent
// window regardless of the parent window's origin. To me, this
// method is insecure because you're basically allowing the code to
// say, "Hey, I have this message I'm going to send and I don't
// care who I send it to since I have a wildcard specified." It is
// my opinion that you always know where your iframe's messages are
// being sent when you create the communication between an iframe
// and its parent window; and that you do not use "*" if you know
// the parent windows origin.
//
// From the MDN:
//
// "Always provide a specific targetOrigin, not *, if you know
// where the other window's document should be located. Failing to
// provide a specific target discloses the data you send to any
// interested malicious site.
//
// Here's what the wildcard method looks like:
//
// parent.postMessage(
// {
// user_age: $("input[name='user_age']").val(),
// user_height: $("input[name='user_height']").val(),
// },
// "*");
});
</script>
</body>
</html>