Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19688

Re: Set iframe src without default.

From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: Set iframe src without default.
Date 2013-05-08 10:25 +0300
Organization A noiseless patient Spider
Message-ID <kmcudi$mkj$1@dont-email.me> (permalink)
References <ouydnaJoPKrz5hTMnZ2dnUVZ_v2dnZ2d@westnet.com.au> <XnsA1BAC97A6977eejj99@194.109.133.133> <fMKdnYzEd8W-WRTMnZ2dnUVZ_q6dnZ2d@westnet.com.au> <kmcoju$v7q$1@dont-email.me> <aOCdnTSpDbHmaxTMnZ2dnUVZ_r-dnZ2d@westnet.com.au>

Show all headers | View raw


2013-05-08 9:53, Andrew Poulos wrote:

> Google says that the only "bad" thing about NOSCRIPT is if you put links
> within a NOSCRIPT element Google will treat them with suspicion. What am
> I missing?

HTML5 CR says:
"The noscript element is a blunt instrument. Sometimes, scripts might be 
enabled, but for some reason the page's script might fail. For this 
reason, it's generally better to avoid using noscript, and to instead 
design the script to change the page from being a scriptless page to a 
scripted page on the fly"
http://www.w3.org/TR/html5/scripting-1.html#the-noscript-element

Although changing the <iframe> element's src attribute value with a 
script means such an approach, the problem with it is, as you have 
noticed, that it changes the rendered page. This is why I suggested a 
different approach, based on resolving the issue server-side, so that 
what the browser gets is ready for display.

If you need to handle this client-side, then the question is how to 
intercept page processing as early as possible, so that when scripting 
is enabled, the <iframe> element will have the right src attribute when 
the browser starts rendering it. Here jQuery might help, see
http://stackoverflow.com/questions/4395780/difference-bw-onload-and-document-readyfunction
(Stay tuned to usual whining about jQuery, usually presented without 
giving any constructive alternative you could actually apply.)

A simpler approach, which might work well enough in practice, is to put 
the <script> element that contains code for changing the src attribute 
right after the <iframe> element.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Set iframe src without default. Andrew Poulos <ap_prog@hotmail.com> - 2013-05-08 08:08 +1000
  Re: Set iframe src without default. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-05-08 01:14 +0200
    Re: Set iframe src without default. Andrew Poulos <ap_prog@hotmail.com> - 2013-05-08 13:18 +1000
      Re: Set iframe src without default. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-05-08 08:45 +0300
        Re: Set iframe src without default. Andrew Poulos <ap_prog@hotmail.com> - 2013-05-08 16:53 +1000
          Re: Set iframe src without default. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-05-08 10:25 +0300
  Re: Set iframe src without default. "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-05-08 08:50 +0300
  Re: Set iframe src without default. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-08 10:25 +0200
    Re: Set iframe src without default. Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-05-09 00:12 +0200
      Re: Set iframe src without default. Christoph Becker <cmbecker69@gmx.de> - 2013-05-09 02:06 +0200
        Re: Set iframe src without default. Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-05-09 11:34 +0200
          Re: Set iframe src without default. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-12 17:46 +0200
  Re: Set iframe src without default. Stefan Weiss <krewecherl@gmail.com> - 2013-05-08 11:35 +0200
    Re: Set iframe src without default. Andrew Poulos <ap_prog@hotmail.com> - 2013-05-08 20:58 +1000
      Re: Set iframe src without default. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-08 14:33 +0200
        Re: Set iframe src without default. Andrew Poulos <ap_prog@hotmail.com> - 2013-05-09 10:10 +1000
          Re: Set iframe src without default. Tim Streater <timstreater@greenbee.net> - 2013-05-09 09:33 +0100
          Re: Set iframe src without default. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-09 12:26 +0200
      Re: Set iframe src without default. Matt McDonald <matt@fortybelow.ca> - 2013-05-08 18:52 -0400
        Re: Set iframe src without default. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-05-09 12:30 +0200

csiph-web