Results 1 to 2 of 2

Thread: help with safari bug (not an easy one!)

  1. #1
    Join Date
    Aug 2010

    Unhappy help with safari bug (not an easy one!)

    I apologize up-front for this being so long of a post, but because there's so much going on in my code, I need to do some heavy explaining before getting to the issue.

    Yesterday I launched the new website for our church at www.trinityumcarlington.org. I designed the site using mootools and some generic javascript. It seems to work fine in IE and FF, but in Safari (at least on mac) the back button causes some major issues. Because of the way the site is set up, the back button functions as follows:

    Whenever a user clicks on a menu option, they do not leave the index.html page. Instead, menu options use Mootools to move images in/out of the screen, simulating the effect of different 'pages'. When the user drills down to the lowest level in a menu option, an iframe is created and a basic html page loaded in it to show the desired text. Since browser history takes into account iframe histories, when the user clicks on another menu option the iframe is disposed of, thereby clearing it's history. This creates the effect of the history always showing 'index.html'. The code I'm using to create/dispose of the iframes is:

      var par = document.getElementById('parentDiv');
      $('parentDiv').setStyle('width', '400px');
      $('parentDiv').setStyle('height', '365px');
      par.innerHTML = '<iframe src="'+subTxt+'" style="width: 375px; position: absolute; height: 365px; left: -25px; top: -10px; border=none;" name="subIframe" id="subIframeID" frameBorder=0></iframe>';
      var t = document.getElementById('parentDiv');
      $('parentDiv').setStyle('width', '0px');
      $('parentDiv').setStyle('height', '0px');
      t.innerHTML = ' ';
    The variable 'subTxt' is set to the dependent html to be loaded in the iframe, based on which menu option is selected by the user.

    Now, to give the browser a functional history to be used with the back button (so that clicking the back button doesn't just take the user back to whatever site they were coming from), I created a small (0x0 to be specific) iframe hidden from view that loads a separate page for each menu option available. The code in one of these html pages looks like:
    <style type="text/css">
    color: #ffffff;
    overflow: hidden;
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js"></script>
    <script type="text/javascript" src="../js/mootoolsmore.js"></script>
    <script type="text/javascript">
    function init(){
    Meanwhile, the function 'BackCheck' that it calls from the parent document contains the following:
    function BackCheck(e){
    if (varX == "false"){}
    else if (varX == "true"){
      if (e=="whoweare"){WhoWeAre()}
      if (e=="ministries"){miniStries()}
      if (e=="spirit"){SpiritDisc()}
      if (e=="involved"){GetInvolved()}
      if (e=="media"){mediaLayout()}
      if (e=="resources"){ResourCes()}
      if (e=="home"){homeB()}
      if (e=="p2k"){p2k()}
      if (e=="adults"){adUltsMinistry()}
      if (e=="child"){childMinstries()}
      if (e=="music"){musicMinistries()}
      if (e=="community"){communityLayout()}
      if (e=="local"){localOutreach()}
      if (e=="congregational"){congregationLayout()}
      if (e=="financial"){financialLayout()}
      if (e=="worship"){worshipLayout()}
    (the variable varX is used on each menu option function by first setting it to 'false', and then running the function, which, among other things, loads the above adults.html file into the hidden iframe, and then sets the varX to 'true' on a delayed call at the end of the function. Thus, when the adults.html (or whichever) is loaded from the menu option function, it sees that that varX is false and does nothing. However, when the user presses the back button, the browser reads the history of the iframe, loads the appropriate html file, which checks and sees that varX is true, and then runs called function - in this case, adUltsMinistry(), as if the user had clicked that menu option.)

    Hopefully that all made sense!

    As I said, this seems to work fine in IE and FF. And it even works in Safari, so long as the user hasn't loaded one of the lowest-level options, thereby creating/disposing the iframe in the 'parentDiv' element. Once that happens, if the user clicks 'back' in Safari, it reloads the entire page, as if 'index.html' was just loaded in the history. I've noticed this happens one of two ways:
    1) the user navigates to menu option 1, then to menu option 2 (where 2 is the lowest level with created iframe), and tries to go back to menu option 1. Upon doing so, the index.html page is reloaded.
    2) the user navigates to menu option 1, then to menu option 2, then to menu option 3 (which is not a lowest-level option), and then tries to go back to option 2. Same result.

    However, if the user goes to menu option 1 then menu option 3 (neither are lowest-level), then goes back to 1, it behaves as intended. Also, if the user goes from 1 to 2 to 3 to 4 (where 4 is also a non-lowest level option), and then goes back to 3, it works fine. Of course, if they hit back again and reload option 2, it reloads index.html.

    You probably just need to load the page and see it for yourself.

    I'm really at a loss for what's going on in Safari. Any help would be greatly appreciated!

  2. #2
    Join Date
    Aug 2010
    Well, I fixed it, although I still don't understand why Safari was causing the problem in the first place. My fix was to take out the following code:

    function removeDiv(){
      var t = document.getElementById('parentDiv');
      t.innerHTML = ' ';
    It still eliminates the iframe from creating an undesired history record as every time the iframe is loaded with content, it is completely created anew using the innerHtml code. But for some reason when the innerHTML for the parentDiv was set to ' ', it caused Safari to not know what to do.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.09161 seconds
  • Memory Usage 2,864KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (2)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates