Skip to content

Commit

Permalink
Removed the base tag from the header of the preview iframe. The href …
Browse files Browse the repository at this point in the history
…and target attributes were causing links within the iframe to open a new tab and would point to /, which created problems with some challenges where users should link to other page elements like a footer.

Fixed an error found in QA where in-page anchors would work as expected in Chrome, but in FireFox would load another instance of Learn in the iframe. If the user goes back to the challenge, though, the in-page anchors work as expected. Readded <base> and had it point to href='' to get in-page anchors working in both Chrome and FF.
  • Loading branch information
scissorsneedfoodtoo authored and raisedadead committed Sep 27, 2018
1 parent b9d38ff commit b29ae0d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/learn/src/templates/Challenges/utils/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ const mainId = 'fcc-main-frame';
const testId = 'fcc-test-frame';

// base tag here will force relative links
// within iframe to point to '/' instead of
// within iframe to point to '' instead of
// append to the current challenge url
// this also allows in-page anchors to work properly
// rather than load another instance of the learn
//
// if an error occurs during initialization
// the __err prop will be set
// This is then picked up in client/frame-runner.js during
// runTestsInTestFrame below
const createHeader = (id = mainId) => `
<base href='/' target='_blank'/>
<base href='' />
<script>
window.__frameId = '${id}';
window.onerror = function(msg, url, ln, col, err) {
Expand Down

0 comments on commit b29ae0d

Please sign in to comment.