Skip to content

Instantly share code, notes, and snippets.

@ungoldman
Created November 1, 2011 20:43
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 ungoldman/1331840 to your computer and use it in GitHub Desktop.
Save ungoldman/1331840 to your computer and use it in GitHub Desktop.
Chrome "Display forbidden by X-Frame-Options" link fix
// Stuck in an iframe? Link throwing an error in Chrome?
// This jQuery snippet will make sure that every link and submit
// without a specified target will open at the window.top.location level.
jQuery(function($){
$(document).on('click', 'a, :submit', function() {
var t = $(this)[0].target; if (t === '') t = '_top';
});
});
<!DOCTYPE HTML>
<html lang='en-US'>
<head>
<meta charset='UTF-8'>
<title></title>
</head>
<body>
<a href="http://youtu.be/zDZFcDGpL4U">link</a>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="script.js">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment