Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-13-2011, 10:00 PM   PM User | #1
justawebbie
New to the CF scene

 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
justawebbie is an unknown quantity at this point
Unhappy document.getElementById(...)' is null or not an object

I get this error in IE only with my javascript can someone help me solve it.

[CODE]Message: 'document.getElementById(...)' is null or not an object
Line: 791
Char: 17
Code: 0[ICode]

my javascript:
[CODE]function pipeCallback16(obj) {
document.write("<div id=leftcol>");
var x;
for (x = 0; x < obj.count ; x++)
{

var buildstring = "<div id='imgbx'><a href='" + obj.value.items[x].galleryURL + "'><img class='imagebx' src='" + obj.value.items[x].imgURL + "' align='left' /></a><p class=imgtxt>" + obj.value.items[x].imageCaption + "<br />" + obj.value.items[x].imageCredit + "</p></div>";
document.write(buildstring);
buildstring = null;
}
document.write("</div>");

}
[ICODE]

Javascript calling from html page:

URL: www.uafcornerstone.com

[CODE]<div id="leftcol">
<script type="text/javascript"
src="http://pipes.yahoo.com/pipes/pipe.run?_id=12ef1dd3ce3549c285885cef75004071&_render=json&_callback=pipeCallback16">
</script>
</div>[ICODE]
justawebbie is offline   Reply With Quote
Old 05-13-2011, 11:05 PM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by justawebbie View Post
I get this error in IE only with my javascript can someone help me solve it.

Code:
Message: 'document.getElementById(...)' is null or not an object
Line: 791
Char: 17
Code: 0
my javascript:
Code:
function pipeCallback16(obj) {
 document.write("<div id=leftcol>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

  var buildstring = "<div id='imgbx'><a href='" + obj.value.items[x].galleryURL + "'><img class='imagebx' src='" + obj.value.items[x].imgURL + "' align='left'  /></a><p class=imgtxt>" + obj.value.items[x].imageCaption + "<br />" + obj.value.items[x].imageCredit + "</p></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}
Javascript calling from html page:

URL: www.uafcornerstone.com

Code:
<div id="leftcol">
<script type="text/javascript"
  src="http://pipes.yahoo.com/pipes/pipe.run?_id=12ef1dd3ce3549c285885cef75004071&_render=json&_callback=pipeCallback16">
  </script>
</div>
code tag ends with [ /code] not icode,
i don't see any getElementById in the code you posted, i miss where it is?
anyway try to look to the line 791 and check if the id is valid and exists in the page and before you use the value check to be valid.

best regards
oesxyl is offline   Reply With Quote
Old 05-14-2011, 02:02 AM   PM User | #3
justawebbie
New to the CF scene

 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
justawebbie is an unknown quantity at this point
document.getElementById(...)' is null or not an object

i am just lost on finding this problem. I will copy and paste my php and if someone could tell me what is wrong with line 791 i think that is what the error said as shown above on original post.

I know there is more than this going into the php. I have widgets, hybird hooks etc. but if someone can help me I would appreciate it.

This is only a problem in IE as mentioned above every other browser shows the image and text for me in the featured photo section of my website. I get no errors until I add my javascript in IE.

header php code:
Code:
<?php
/**
 * Header Template
 *
 * The header template is generally used on every page of your site. Nearly all other
 * templates call it somewhere near the top of the file. It is used mostly as an opening
 * wrapper, which is closed with the footer.php file. It also executes key functions needed
 * by the theme, child themes, and plugins. 
 *
 * @package Hybrid
 * @subpackage Template
 */
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />
<title><?php hybrid_document_title(); ?></title>
<script type="application/javascript">
function pipeCallback16(obj) {
 document.write("<div id=leftcol>");
 var x;
 for (x = 0; x < obj.count ; x++)
 {

  var buildstring = "<div id='imgbx'><a href='" + obj.value.items[x].galleryURL + "'><img class='imagebx' src='" + obj.value.items[x].imgURL + "' align='left'  /></a><p class=imgtxt>" + obj.value.items[x].imageCaption + "<br />" + obj.value.items[x].imageCredit + "</p></div>";
  document.write(buildstring);
  buildstring = null;
 }
 document.write("</div>");

}

</script>
<link rel="shortcut icon" href="http://www.uafcornerstone/favicon.ico" /> 
<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="all" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />

<?php do_atomic( 'head' ); // @deprecated 0.9.0. Use 'wp_head'. ?>
<?php wp_head(); // wp_head ?>

</head>

<body class="<?php hybrid_body_class(); ?>">

<?php do_atomic( 'before_html' ); // hybrid_before_html ?>

<div id="body-container">

	<?php do_atomic( 'before_header' ); // hybrid_before_header ?>

	<div id="header-container">

		<div id="header">

			<?php do_atomic( 'header' ); // hybrid_header ?>

		</div><!-- #header -->

	</div><!-- #header-container -->

	<?php do_atomic( 'after_header' ); // hybrid_after_header ?>

	<div id="container">

		<?php do_atomic( 'before_container' ); // hybrid_before_container ?>
Main front page code

Code:
<?php
/**
 * Template Name: Front Page
 *
 * Useful for sites that need a news-type front page.
 *
 * @package HybridNews
 * @subpackage Template
 */

/* Get the Hybrid News theme settings. */
$hybrid_news = get_option( 'hybrid_news_theme_settings' );

get_header(); ?>

	<div class="hfeed content">

		<?php hybrid_before_content(); // Before content hook ?>

		<!-- Begin feature slider. -->
		<div id="slider-container">

			<div id="slider">

			<?php
				if ( $hybrid_news['feature_category'] )
					$feature_query = array( 'cat' => $hybrid_news['feature_category'], 'showposts' => $hybrid_news['feature_num_posts'], 'caller_get_posts' => 1 );
				else
					$feature_query = array( 'post__in' => get_option( 'sticky_posts' ), 'showposts' => $hybrid_news['feature_num_posts'] );
			?>

				<?php $loop = new WP_Query( $feature_query ); ?>

				<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

					<div class="<?php hybrid_entry_class( 'feature' ); ?>">

						<?php get_the_image( array( 'custom_key' => array( 'Medium', 'Feature Image' ), 'size' => 'medium' ) ); ?>

						<?php hybrid_before_entry(); ?>

						<div class="entry-summary">
							<?php the_excerpt(); ?>
							<a class="more-link" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php _e('Full Story &raquo;', 'news'); ?></a>
						</div>

						<?php hybrid_after_entry(); ?>

					</div>

				<?php endwhile; ?>

			</div>

			<div class="slider-controls">
				<a class="slider-prev" title="<?php esc_attr_e( 'Previous Post', 'hybrid-news' ); ?>"><?php _e( 'Previous', 'hybrid-news' ); ?></a>
				<a class="slider-pause" title="<?php esc_attr_e( 'Pause', 'hybrid-news' ); ?>"><?php _e( 'Pause', 'hybrid-news' ); ?></a>
				<a class="slider-next" title="<?php esc_attr_e( 'Next Post', 'hybrid-news' ); ?>"><?php _e( 'Next', 'hybrid-news' ); ?></a>
			</div>

		</div>
		<!-- End feature slider. -->

		<!-- Begin excerpts section. -->
		<div id="excerpts">

			<?php $loop = new WP_Query( array( 'cat' => $hybrid_news['excerpt_category'], 'showposts' => $hybrid_news['excerpt_num_posts'], 'caller_get_posts' => 1, 'post__not_in' => $do_not_duplicate ) ); ?>

			<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

				<div class="<?php hybrid_entry_class(); ?>">

					<?php get_the_image( array( 'custom_key' => array( 'Thumbnail' ), 'size' => 'thumbnail' ) ); ?>

					<?php hybrid_before_entry(); ?>

					<div class="entry-summary">
						<?php the_excerpt(); ?>
					</div>

					<?php hybrid_after_entry(); ?>

				</div>

			<?php endwhile; ?>

		</div>
		<!-- End excerpts section. -->
        <?php $hybrid_news['headlines_category'] = array( '3', '4', '5','8', '7', '6' ); ?>

		<?php if ( !empty( $hybrid_news['headlines_category'] ) ) : $alt = 'odd'; ?>

			<!-- Begin category headlines section. -->
			<div id="headlines">

			<?php foreach ( $hybrid_news['headlines_category'] as $category ) : ?>

				<?php $headlines = get_posts( array(
					'numberposts' => $hybrid_news['headlines_num_posts'], 
					'category' => $category, 
					'post__not_in' => $do_not_duplicate
				) ); ?>

				<?php if ( !empty( $headlines ) ) : ?>

					<div class="section <?php echo $alt; ?>">

						<?php $cat = get_category( $category ); ?>

						<h3 class="section-title"><a href="<?php echo get_category_link( $category ); ?>" title="<?php echo esc_attr( $cat->name ); ?>"><?php echo $cat->name; ?></a></h3>

						<ul>
						<?php foreach ( $headlines as $post ) : $do_not_duplicate[] = $post->ID; ?>
							<li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> </li>
						<?php endforeach; ?>
						</ul>

					</div>

					<?php $alt = ( ( $i++ % 2 == 0 ) ? 'even' : 'odd' ); ?>

				<?php endif; ?>

			<?php endforeach; ?>

			</div>
			<!-- End category headlines section. -->

		<?php endif; // End check if headline categories were selected. ?>

		<?php hybrid_after_singular(); // After singular hook ?>

		<?php hybrid_after_content(); // After content hook ?>

	</div><!-- .content .hfeed -->

<?php get_footer(); ?>
The hooks have information in it as well! I can get that information and paste as well.

Footer php code

Code:
<?php
/**
 * Footer Template
 *
 * The footer template is generally used on every page of your site. Nearly all other
 * templates call it somewhere near the bottom of the file. It is used mostly as a closing
 * wrapper, which is opened with the header.php file. It also executes key functions needed
 * by the theme, child themes, and plugins. 
 *
 * @package Hybrid
 * @subpackage Template
 */
?>
		<?php hybrid_after_container(); // After container hook ?>

	</div><!-- #container -->

	<div id="footer-container">

		<?php hybrid_before_footer(); // Before footer hook ?>

		<div id="footer">

			<?php hybrid_footer(); // Hybrid footer hook ?>

		</div><!-- #footer -->

		<?php hybrid_after_footer(); // After footer hook ?>

	</div><!-- #footer-container -->

</div><!-- #body-container -->

<?php wp_footer(); // WordPress footer hook ?>
<?php hybrid_after_html(); // After HTML hook ?>

</body>
</html>
justawebbie is offline   Reply With Quote
Old 05-14-2011, 02:20 AM   PM User | #4
kansel
Regular Coder

 
Join Date: Jul 2002
Location: Kansas, USA
Posts: 465
Thanks: 0
Thanked 45 Times in 44 Posts
kansel is on a distinguished road
Line 791 refers to the HTML source as seen by the browser. Please run your PHP through a browser then paste the code from View Source. Who knows where the error might be in your pre-processed PHP, certainly not on line 791.
kansel is offline   Reply With Quote
Reply

Bookmarks

Tags
document.getelementbyid, ie error, javascript

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:07 AM.


Advertisement
Log in to turn off these ads.