Results 1 to 6 of 6

Thread: Cross Browser Way of Taking Block Node Containing Text Into Child Window

  1. #1
    Join Date
    Jul 2010

    Cross Browser Way of Taking Block Node Containing Text Into Child Window

    My parent window has a button with the containing text "Show Help".

    The help text is supposed to be presented in a child window.

    The button runs a script that

    • Retrieves a DOM node of a DIV element containing the help text, with the DIV element CSS property 'display:none;' set
    • Opens up a child window
    • Passes the DOM node to a function that has an argument for specifying the content of the body of the child Window

    In the past, I would write out the text contained by the DIV element as a Javascript string, containing the HTML markup, and then use document.write() calls in the child window. It is inconvenient to write out long Javascript strings with HTML markup (hard to debug). Also document.write() calls are deprecated by some developers (and don't work for XHTML anyway); DOM methods (appendChild() etc) are preferred.

    So I tried using approved methods---which does not include making use of the nonstandard properties outerHTML or innerHTML. I have been testing with FF17, IE9, and Chrome23 in Win7, FF17 in Ubuntu Linux, and IE8 in Win XP. In most cases, IE8 in WinXP is the problem.

    I am using .importNode() and only "standardized" methods and properties (ECMA, W3C).

    But there are aggravating problems. For example, importNode() works in Firefox, but when I scripted this in FF17 (Win7), it was reporting that childWin.document.body (namely, the body DOM node) was null! If I ran the script in the debugger, the body node was not null! The body node was being referenced in script after the document.close() call, which was itself subsequent to a number of document.write() calls. It was clear that the body node presence was time-dependent...and an onload event seemed to be necessary (why??). But when I write an onload event, it never triggered! These are the aggravations.

    And then there is the problem of still writing the code to do the same for IE8 and IE7 earlier versions. Probably I will have to just pass a string made of HTML markup as the body, and use a document.write() call. Not good.

    Has anyone else worked on this?

  2. #2
    Join Date
    Aug 2008
    Do you have to use a popup window? Maybe a pop-in "window" would be better?

  3. #3
    Join Date
    Jul 2010
    Quote Originally Posted by refreezed View Post
    Do you have to use a popup window? Maybe a pop-in "window" would be better?
    Do you have a link to working example script that does not make use of a library (jQuery, Prototype, etc) at all?

  4. #4
    Join Date
    Dec 2012
    How about something like this? Just have a hidden "popup" div that appears when the buttons clicked (then vanishes after a set time)

    HTML Code:
    <!doctype html>
    <html lang="en">
    		<meta charset="utf-8"/>
    		<style type="text/css">
    			#popup {
    				display: none;
    				position: absolute;
    				top: 50px;
    				width: 200px;
    				padding: 10px;
    				background-color: #333;
    				color: #fff;
    		<button id="help">Help</button>
    		<div id="popup">
    			<p>Here's a bunch of helpful words</p>
    		<script type="text/javascript">
    			var helpBtn = document.getElementById('help');
    			var popup = document.getElementById('popup');
    			helpBtn.addEventListener ? helpBtn.addEventListener('click',showHelp) : helpBtn.attachEvent('onclick',showHelp);
    			function showHelp(e) {
    				popup.style.display = "block";
    				popup.style.left = (document.documentElement.offsetWidth / 2) - (popup.offsetWidth / 2)+"px";
    				setTimeout(function() {
    					popup.style.display = "none";
    				if(e.preventDefault) {
    				} else {
    					return false;

  5. #5
    Join Date
    Jun 2009
    The thing about a non-displayed block element that suddenly appears is that all other elements are sort of pushed around (re-flowed), and that can be unnerving for the user.

    One way around it might be:

    * the block element (DIV) that is suddenly displayed is done so in a z-layer

    * the block element is positioned using CSS (the absolute or fixed property?) and this does NOT cause a re-flowing of the other elements

    Will this strategy work? And does it work in IE8 and IE7?

  6. #6
    Join Date
    Dec 2012
    Elements that are absolutely positioned or fixed are taken out of the regular flow and have no effect on other elements, it works in every browser.

Thread Information

Users Browsing this Thread

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

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.12689 seconds
  • Memory Usage 2,893KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (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
  • (1)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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 (70):
  • 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_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_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