Problem with IE when I use frames[rte].document?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jan Ebbe Jensen

    Problem with IE when I use frames[rte].document?

    Hi

    I have tried the following code. It works in Mozilla. In IE I'm not able to
    enable DesignMode? What have I done wrong? It says that obj is undefined?
    Can anyone help me please.







    <html>

    <head>



    <script type="text/javascript">



    function initRTE (html, width, height) {

    this.html = html;

    this.width = width;

    this.height = height;

    }



    initRTE.prototy pe.makeRTE = function() {

    document.writel n('<iframe src="blank.htm" id="rte1" name="rte1" width="' +
    this.width + 'px" height="' + this.height + 'px"></iframe>');

    alert("getEleme ntById: " + document.getEle mentById('rte1' ));

    this.enableDesi gnMode("rte1", this.html);

    }



    initRTE.prototy pe.enableDesign Mode = function(rte, html) {



    alert("enableDe signMode getElementById: " +
    document.getEle mentById('rte1' ));

    var frameHtml = "<html>\n";

    frameHtml += "<head>\n";

    frameHtml += "</head>\n";

    frameHtml += "<body>\n";

    frameHtml += html + "\n";

    frameHtml += "</body>\n";

    frameHtml += "</html>";

    if (document.all) {

    var obj = frames[rte].document;

    alert("obj " + obj);

    obj.open();

    obj.write(frame Html);

    obj.close();

    obj.designMode = "on";

    } else {

    try {

    document.getEle mentById(rte).c ontentDocument. designMode = "on";

    try {

    obj =
    document.getEle mentById(rte).c ontentWindow.do cument;

    obj.open();

    obj.write(frame Html);

    obj.close();

    } catch (e) {



    }

    } catch (e) {



    }

    }

    }

    </script>

    </head>

    <body>



    <form name="form" action="" method="get">

    <script language="JavaS cript" type="text/javascript">



    // initRTE (html, width, height)

    var rte1 = new initRTE ("Just some text....", 560, 200);

    rte1.makeRTE();



    </script>

    </form>

    </body>

    </html>



    Thanks for any help!

    Jan Ebbe Jensen


  • Nathan Sokalski

    #2
    Re: Problem with IE when I use frames[rte].document?

    I just want to let you know that it is not a good idea to use frames. They
    are deprecated, and also have some small security issues. They are also not
    supported by all browsers and some older versions of certain browsers do not
    always render them correctly. If you really need to combine multiple
    documents, I would suggest using Server-Side Includes (the name may sound
    scary, but they are really quite easy) and layout the page with tables. If
    you are dynamically changing the content of a frame using Javascript and
    don't want to learn a new complicated technology, I would suggest looking
    into ASP (not ASP.NET, ASP.NET is much more complicated). But as useful as
    frames may seem, they can be very dangerous, and are not usually worth using
    a deprecated technology.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。


    "Jan Ebbe Jensen" <janebbe@tdcads l.dk> wrote in message
    news:427bbdc9$0 $309$edfadb0f@d read11.news.tel e.dk...[color=blue]
    > Hi
    >
    > I have tried the following code. It works in Mozilla. In IE I'm not able
    > to enable DesignMode? What have I done wrong? It says that obj is
    > undefined? Can anyone help me please.
    >
    >
    >
    >
    >
    >
    >
    > <html>
    >
    > <head>
    >
    >
    >
    > <script type="text/javascript">
    >
    >
    >
    > function initRTE (html, width, height) {
    >
    > this.html = html;
    >
    > this.width = width;
    >
    > this.height = height;
    >
    > }
    >
    >
    >
    > initRTE.prototy pe.makeRTE = function() {
    >
    > document.writel n('<iframe src="blank.htm" id="rte1" name="rte1" width="'
    > + this.width + 'px" height="' + this.height + 'px"></iframe>');
    >
    > alert("getEleme ntById: " + document.getEle mentById('rte1' ));
    >
    > this.enableDesi gnMode("rte1", this.html);
    >
    > }
    >
    >
    >
    > initRTE.prototy pe.enableDesign Mode = function(rte, html) {
    >
    >
    >
    > alert("enableDe signMode getElementById: " +
    > document.getEle mentById('rte1' ));
    >
    > var frameHtml = "<html>\n";
    >
    > frameHtml += "<head>\n";
    >
    > frameHtml += "</head>\n";
    >
    > frameHtml += "<body>\n";
    >
    > frameHtml += html + "\n";
    >
    > frameHtml += "</body>\n";
    >
    > frameHtml += "</html>";
    >
    > if (document.all) {
    >
    > var obj = frames[rte].document;
    >
    > alert("obj " + obj);
    >
    > obj.open();
    >
    > obj.write(frame Html);
    >
    > obj.close();
    >
    > obj.designMode = "on";
    >
    > } else {
    >
    > try {
    >
    > document.getEle mentById(rte).c ontentDocument. designMode = "on";
    >
    > try {
    >
    > obj =
    > document.getEle mentById(rte).c ontentWindow.do cument;
    >
    > obj.open();
    >
    > obj.write(frame Html);
    >
    > obj.close();
    >
    > } catch (e) {
    >
    >
    >
    > }
    >
    > } catch (e) {
    >
    >
    >
    > }
    >
    > }
    >
    > }
    >
    > </script>
    >
    > </head>
    >
    > <body>
    >
    >
    >
    > <form name="form" action="" method="get">
    >
    > <script language="JavaS cript" type="text/javascript">
    >
    >
    >
    > // initRTE (html, width, height)
    >
    > var rte1 = new initRTE ("Just some text....", 560, 200);
    >
    > rte1.makeRTE();
    >
    >
    >
    > </script>
    >
    > </form>
    >
    > </body>
    >
    > </html>
    >
    >
    >
    > Thanks for any help!
    >
    > Jan Ebbe Jensen
    >[/color]


    Comment

    • Dr John Stockton

      #3
      Re: Problem with IE when I use frames[rte].document?

      JRS: In article <GOtfe.3933$nX1 .1593@trnddc09> , dated Sun, 8 May 2005
      19:31:50, seen in news:comp.lang. javascript, Nathan Sokalski
      <njsokalski@ver izon.net> posted :

      Please do not over-quote.

      Please do not top-post.

      Please do not put a signature separator in the middle of a message.

      Please read the newsgroup FAQ.
      [color=blue]
      >I just want to let you know that it is not a good idea to use frames. They
      >are deprecated, and also have some small security issues. They are also not
      >supported by all browsers and some older versions of certain browsers do not
      >always render them correctly.[/color]

      Security apart, those are not good reasons not to have frames; they are
      only good reasons for not relying on using frames.

      A site designed for use without frames can, with little effort, have
      indexing frames as a reader-selected option.

      Indeed, since screens and viewports vary in width, a wide-view reader
      who has chosen to see the framed view can have a normal-view window
      showing the main material, with a site-navigation frame, or frames,
      added on the left as a scrollable column.


      My pages have a "Frame This" link near the top; users with javascript
      and frames will (AFAIK, in all browsers) then get the page framed, while
      others will get a suitable response. They also have a "No-Frame" link.

      [color=blue]
      >"Jan Ebbe Jensen" <janebbe@tdcads l.dk> wrote in message
      >news:427bbdc9$ 0$309$edfadb0f@ dread11.news.te le.dk...[color=green]
      >> Hi
      >>
      >> ... ... ...[/color][/color]

      --
      © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
      <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
      <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
      <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Problem with IE when I use frames[rte].document?

        Nathan Sokalski wrote:
        [color=blue]
        > I just want to let you know that it is not a good idea to use frames.[/color]

        Even though your intention is valid, your argumentation is badly flawed:
        [color=blue]
        > They are deprecated,[/color]

        They have been deprecated by some W3C guys (without endorsement by all
        members) since the time of XHTML 1.0. The same W3C guys recommend to
        use client-side scripting instead of the `target' attribute, ignoring
        that client-side scripting is not in the half of the cases available
        that frame support is today. Not a good reason.
        [color=blue]
        > and also have some small security issues.[/color]

        Not a good reason. There are much more security issues not related to
        frames than related to them.
        [color=blue]
        > They are also not supported by all browsers[/color]

        Not a good reason and not a problem, as those browsers (have to) provide
        alternatives to access frame content. E.g. `lynx' as a text-only browser
        does not support frames (even though `links' which also is a text-only
        browser does), displays frame references as links.
        [color=blue]
        > and some older versions of certain browsers do not always render them
        > correctly.[/color]

        At first you argue that they are deprecated (which applies for recent user
        agents) and then you argue that older (!recent) user agents don't support
        them properly. That's a contradiction. Furthermore, in that case those
        older user agents are borken and do not require nor do they deserve support
        from a reasonable Web author/programmer.
        [color=blue]
        > f you really need to combine multiple documents, I would suggest using
        > Server-Side Includes (the name may sound scary, but they are really quite
        > easy)[/color]

        But that would increase server load and it would increase bandwidth usage
        compared to a site built on frames.
        [color=blue]
        > and layout the page with tables.[/color]

        Certainly not. Tables are for tabular data, not for layout:
        A table is a table is a table. [psf 3.8] (Learn to) use CSS instead.
        [color=blue]
        > If you are dynamically changing the content of a frame using Javascript
        > and don't want to learn a new complicated technology, I would
        > suggest looking into ASP (not ASP.NET, ASP.NET is much more complicated).[/color]

        That would be (Microsoft) JScript, not (Netscape) Java[sS]cript.
        [color=blue]
        > But as useful as frames may seem, they can be very dangerous, and are
        > not usually worth using a deprecated technology.[/color]

        A good reason for using frames is usability. It makes a Web site less
        usable to have all content reloaded if only a short portion of that
        changes. Time is money.

        A good reason for *not* using frames is usability. It is harder to
        bookmark specific content on a Web site when it is built on frames.

        But no such good reason for or against frames has been presented by you,
        which makes me wonder whether you gave or your argumentation not enough
        thought or just copy-pasted it without thought from someone/-where.


        PointedEars
        --
        Bill Gates isn't the devil -- Satan made sure hell
        _worked_ before he opened it to the damned ...

        Comment

        Working...