Results 1 to 10 of 10

Thread: Complicated mess of javascript and frames

  1. #1
    Join Date
    May 2014
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default Complicated mess of javascript and frames

    i have a large and rather outdated mess on my site, that employs html frameset
    and javascript:loadFrames, which allows me to load different html pages in the parts of the frameset with one click.
    however, i have recently added a transparent background iframe to the mix, and can't seem to figure out
    a way to make the javascript:load frames to target the iframe, particularly since it is on another page. here's the
    javascript:loadFrames script. keep in mind, that i currently only have 2 html frame windows in the frameset: menu and content
    and then of course, the new iframe.

    <!-- Begin
    function loadFrames

    (frame1,page1,frame2,page2,frame3,page3,frame4,page4) {
    eval("parent."+frame1+".location='"+page1+"'");
    eval("parent."+frame2+".location='"+page2+"'");
    eval("parent."+frame3+".location='"+page3+"'");
    }
    // End -->

    </script>

    ----

    <a href="javascript:loadFrames( 'menu', '.html',

    'content','.html' )"><img src=".jpg" border=0

    width="17%"></a>

    ------

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,952
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    You can load pages into the two frames in the frameset because they are there. However, the iframe isn't there until the page that has the iframe is in the frame into which it is being loaded and that page is parsed by the browser. Assuming the iframe is on the page loaded into the content frame and is a named iframe one could do:

    Code:
    function loadFrames(frame1,page1,frame2,page2,frame3,page3,frame4,page4) {
    	parent[frame1].location = page1;
    	parent[frame2].onload = function(){
    		parent[frame2].frames[frame3].location = page3;
    		parent[frame2].onload = function(){};
    	};
    	parent[frame2].location = page2;
    }
    But, if there is not always an iframe on the second page, you will have an error in those cases. And if the second page has its own onload function, it will overwrite the one in the above function before it's executed. These issues could be overcome by using version 5 events for the load event and testing for the existence of the iframe before trying to load to it. To do that, replace the above with:

    Code:
    var addEvent = (function(){return window.addEventListener? function(el, ev, f){
    		el.addEventListener(ev, f, false);
    	}:window.attachEvent? function(el, ev, f){
    		el.attachEvent('on' + ev, f);
    	}:function(){return;};
    })();
    var removeEvent = (function(){return window.removeEventListener? function(el, ev, f){
    		el.removeEventListener(ev, f, false);
    	}:window.detachEvent? function(el, ev, f){
    		el.detachEvent('on' + ev, f);
    	}:function(){return;};
    })();
    function loadFrames(frame1,page1,frame2,page2,frame3,page3,frame4,page4) {
    	parent.frames[frame1].location = page1;
    	function loadIframe(){
    		if(frame3 && page3 && this.frames[frame3]){this.frames[frame3].location = page3;}
    		removeEvent(this, 'load', loadIframe);
    	}
    	addEvent(parent.frames[frame2], 'load', loadIframe);
    	parent.frames[frame2].location = page2;
    }
    There's a lot that might go wrong with this, but the idea is sound. So, if there are problems they can probably be worked out.

    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    jundo12 (05-02-2014)

  4. #3
    Join Date
    May 2014
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    here it is. it's messy and old school but was the only way i could solve the problems without learning a bunch of new programming languages, and i'm just a little old lady lol it's obviously not done.
    http://thelivingmoon.com/undomiel/in...rthfemale.html

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,952
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Where's the iframe? Where's the code I wrote for you?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #5
    Join Date
    May 2014
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    i haven't put it in yet, cause you had said it would have to be refreshed, and i was assuming (maybe i'm wrong?) that you meant the player would have to do that. at the time, i hadn't mentioned that it was a game, so i guess i thought you were saying that it would need be buggy and have to be refreshed, to clear cache etc. how would i implement that? leave the other where it is and just add that to the head? i'm a bit confused about how it works.

  7. #6
    Join Date
    May 2014
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    p.s. how then do i target the iframe in the actual link that targets the iframe?
    will this allow me to target the iframe's name even though it's not a part of the frameset? "javascript:loadFrames( 'menu', '.html',

    'content','.html' )"

    like, would i put 'menu', 'pagewhatever.html','content','anotherwhatever.html','iframe',theiframepage.html' ?

  8. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,952
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Whenever you make changes to a site, you will have to wait until the user's browser no longer caches the old material before the new material is available. Usually this will not take long. Some servers force this to happen sooner than others. But it cannot start to happen until the change(s) are made. With such a complex setup, bugs can happen. But those can't be fixed until you tell me about them and/or I notice them, which again cannot happen until the change(s) are made. Mostly the caveat about refreshing and clearing the cache is for you looking at the pages after changes. Most users are doing so many other things in the meantime that they will not be holding your pages in cache very long.

    One thing that's important with something like this though is to be sure to backup what you have before changing it.

    And when you change a game's site, it sometimes cannot be avoided that the game might have to be started over. I don't think that would happen with the changes we've been discussing. But you know the game much better than I do, as well as what the iframe is going to be for, so you would be the better judge of that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #8
    Join Date
    May 2014
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    oh i guess i need to tell you what the iframe is for. i wanted it to be the place where the person's choice of avatar + its modifications, would appear as 3rd person perspective at the bottom of the page, like the footer frame is currently doing. then i could make the iframe transparent, have it mesh with the site better, and not have so many problems getting things to match up. having that long footer at the bottom, that was also rather tall, was eating up alot of the game screen, too. only problem i can think of with it is, that it isn't like the html frameset frames, in that it isn't going to sticky to that player's window in the same way as the html frameset frames do, and that's something that may cause problems. i can't just run one html page in the main window and have the html frameset frames fit into it as customized game choices the player has made. otherwise,i have to start messing around with saving data in the browser memory, and that's beyond my abilities. when i read up on how it works, it just sounded like charlie brown's teacher. if'n ya know what i mean.

    anyway, can i target the iframe from the actual link html now? notice the javascript loadframe html i use to load the frameset frames, requires a certain syntax that is specific to framesets. will it now accept the iframe as one of its html frames?

  10. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,952
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Reread my first post in this thread. And instead of backing up what you have, keep what you have as it is. Make a separate folder and copy the site there and then experiment in there using the code I've written for you. If after trying it out you are having problems, let me know and I'll have a look at it.

    But you're right. You are not going to be able to have a static page in the iframe unless the page holding the iframe never changes. From what you seem to be saying, that's not how you have envisioned this. You might be able to have the static frame take up less room by adding more frames.
    Last edited by jscheuer1; 05-03-2014 at 04:02 AM. Reason: add 2nd paragraph
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  11. #10
    Join Date
    May 2014
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    i tried it on my desktop and i realized it will create the problem of loss of static retention of the player's choices. i would still end up with having to create 162 different folders each with the same pages repeated with only player specific changes to each page. that's way over the top at this point because there are 9 race choices, each with 2 gender choices, and each with 2 modification choices, and then the results displayed in 2 different locations (the side frame and the footer or iframe), not to mention a third full view loaded into the side frame and a head only view in the side frame. only way to solve it is to keep the footer. i created a thread in the html forum here, to address this particular problem since it is html frameset issue

Similar Threads

  1. Over all mess
    By *Warrior* in forum CSS
    Replies: 5
    Last Post: 07-13-2008, 12:33 AM
  2. Help with Javascript and Frames
    By Tifoso in forum JavaScript
    Replies: 9
    Last Post: 07-08-2008, 05:05 PM
  3. CSS Top and Bottom Frames Layout Bookmarks mess up.
    By WaxonWaxov in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-01-2008, 05:20 PM
  4. Javascript in Frames! How to Target?!
    By THUNDER in forum JavaScript
    Replies: 0
    Last Post: 03-11-2007, 05:02 AM
  5. Javascript & frames
    By Nux in forum JavaScript
    Replies: 0
    Last Post: 04-24-2006, 07:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •