Skip to content

Instantly share code, notes, and snippets.

@Xiphe
Last active December 18, 2015 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xiphe/5756516 to your computer and use it in GitHub Desktop.
Save Xiphe/5756516 to your computer and use it in GitHub Desktop.
Parameterübergabe an Popups
<html>
<head>
<title>Parameter Uebergabe JS</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
$('#preview_link').click(function(event) {
event.preventDefault();
var popup = window.open(
'preview.html',
'Vorschau',
'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no'
);
});
window.getForm = function() {
return $('#form').serializeArray();
};
});
</script>
</head>
<body>
<form id="form">
<input name="foo" value="bar" />
<input name="fop" value="bas" />
<input name="foq" value="bat" />
<input name="for" value="bau" />
<input name="fos" value="bav" />
<input name="fot" value="baw" />
</form>
<a href="#preview" id="preview_link">Preview</a>
</body>
</html>
<html>
<head>
<title>Parameter Empfaenger JS</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
var parent = window.opener;
$.each(parent.getForm(), function(i, input) {
$('body').append('<div>'+input.name+': '+input.value+'</div>');
});
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment