Jump to content
dansbanners

Questions about Document Write

Recommended Posts

The following codes
 
Quote:
document.write('<a'+link+'" target="_blank"><img src="'+adBanner+'" width="125" height="125" alt="'+alt+'" title="'+title+'" /></a>');
 Is causing this error message:
 
Quote:
document type does not allow element "a" here

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements Does anyone have any suggestion on how to fix the above dilemma? Thanks.
Can the document write be written in a different way other than the one shown above in this thread? Thanks in advance!
Reply With Quote

Share this post


Link to post
Share on other sites

It sounds like you have something that is confused about your code and thinks that the string inside your Javascript code is actually HTML code instead of a Javascript string.  The bug is in whatever is giving you that message, assuming the rest of your HTML code is structured correctly (e.g., that Javascript code is inside a script element).

Share this post


Link to post
Share on other sites

You can replace the < with &lt;. The message you're showing looks like it's from an HTML validator, not a browser.

Share this post


Link to post
Share on other sites

You appear to have left out the href attribute.

Try the following:

document.write('<a href="' + link + '" target="_blank"><img src="' + adBanner + '" width="125" height="125" alt="' + alt + '" title="' + title + '" /></a>');

Roddy

p.s.  If it helps, hover over the heart and click on the trophy that results.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...