Jump to content

Questions about Document Write


dansbanners

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
Link to comment
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).

Link to comment
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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...