When building a SCORM solution from html and javascript where tracking with the LMS is required, is it still necessary to contain all pages in an IFRAME or are other approaches being adopted? What difficulties does working within an IFRAME present when trying to create responsive pages?
问题:
回答1:
There's no need to use IFRAMES or OBJECTS to contain your SCORM content. The API is simply Javascript, and as long as it's all included in the page everything will work (the SCORM conformance reqs basically require you to look in your own frame, then any parent frames, then any parent window)...
Saying that - whatever platform you are using needs to allow you to have the content in there directly, and most simply put it into some sort of frame / window by default.
回答2:
As the other posters mention, technically frames were never required, but they are by far the easiest and most reliable way to ensure the SCORM API remains available as you navigate between multiple pages.
If you don't use an iframe (maintaining the API connection in the parent frame), and the user navigates to the second page of your course, it will break the API connection and the course will no longer be able to communicate with the LMS.
The parent frame handles the communication with the LMS while the child frame contains the course content. The child frame (usually an iframe) can be maximized to fit the entire viewport, rendering the parent frame invisible and enabling the child frame to feel/behave as a single HTML page.
RE: Responsive layout, iframes are not a barrier to creating responsive layouts. We do it all the time. Set the iframe to take up 100% width/height of the parent frame (overflow: hidden on parent frame, overflow: auto on child frame so the scrollbars show up as desired). At this point, any responsive code you use within the iframe's HTML should work the same as it would if it were NOT in an iframe. For example, if you use a media query to stack elements when the viewport is small (eg a tablet or phone), the media query should fire just fine. SCORM has no impact on CSS, and the iframe's impact on your CSS/design is negligible if managed well.
iframes are a big part of modern web sites, and are part of the HTML5 spec; support for iframes is very robust across browsers and devices. Don't let it scare you.
回答3:
This answer assumes the question means: 'Do iframes have to be used in the complete solution including the LMS and content?'
Remember that SCORM is now quite an old specification so wasn't designed with the modern world in mind. SCORM uses a JavaScript API and needs to have a parent-child relationship between the LMS window and the content. That means you have a choice of:
- Pop-ups, which are blocked by default in many browsers.
- Framesets, which are 'obsolete' and now longer supported in HTML5.
- Iframes, which as you mentioned can cause problems for responsivity. See this stack overflow question for some suggestions.
The successor of SCORM, Tin Can API uses HTTP requests instead of a JavaScript API. With Tin Can, you can launch content in a new window, in the same window, on another device or however you like. Pop-ups and frames are not required.
If the question is 'Do I have to use iframes in my content?', the answer is no.