views:

98

answers:

2

Hello guys, my webpage is www.bodrum_dev.info (Remove the underscore character from two words).

I am trying to validate my page, but featured news section (that changes article headline and image on the left when mouse over to titles) generates 30 errors.

I know the reason. Because i have h1 h2 and div tags inside an a tag. So basically removing parent a tag and placing a tags inside h1 h2 and div probably would fix the issue. However, my template uses jquery to tell what to do when mouse overing, so editing my template breaking my page. And it simply does not behave correctly. How can i validate my page without breaking mouseover effects? Related files are below:

Following is my template:

<div class="newsWrap"><ul><li>
  <a href="[ARTICLELINK]">
    <h1 style="height: 90px;">
      <img border="0" src="/DesktopModules/DnnForge%20-%20NewsArticles/Headline.ashx?c=[CUSTOM:MANSET]&amp;fc=[CUSTOM:COLOR]" alt="[TITLE]" />
    </h1>
<h2 style="margin-top: 28px;margin-left: 5px;">
      [HASSUMMARY][SUMMARY][/HASSUMMARY][HASNOSUMMARY][DETAILS:150][/HASNOSUMMARY]
    </h2>
<div class="laImage">[IMAGETHUMB:200:265]</div>
<span>[TITLE]</span>
  </a>
</li></ul></div>

Following is my jquery entries:

<script type="text/javascript">
jQuery().ready(function() {
jQuery(".newsWrap a:first").addClass('selected');
jQuery(".newsWrap a").mouseover(function(){
    jQuery('.newsWrap a.selected').removeClass('selected');
    jQuery(this).addClass('selected');
});
});
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt;
    <script type="text/javascript">
     $(document).ready(function() {
        $('.koseContent p').each(function(){
            $(this).css('marginTop',(52-$(this).height())/2);
        }).show();
    });
    </script>
<script type="text/javascript" src="/js/jquery.cycle.lite.1.0.min.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
// 
jQuery(document).ready(function(){
jQuery('table.RandomView').wrap("<div id='imageSwapper'></div>");
jQuery('table.RandomView').attr({align: "left"});
jQuery('table.RandomView').cycle({
    timeout:4000,
    speed:  1000,
    slideExpr: 'td div.sgWrap'
});
jQuery('table.RandomView tr').show();
});/* ]]> */
</script>

Following is my css:

div.newsWrap {
    width:493px;
    height:410px;
    margin:0 10px;
    position:relative;


overflow:hidden;
    background-color:#fff;
}
div.newsWrap li{
    height:16px;
    margin-bottom:12px;
    background:

url(images/mandalina.gif) bottom left no-repeat scroll;
}
/* Element position */
div.newsWrap div.laImage {
    display:none;


position:absolute;
    top:130px;
    left:0;
    width:250px;      /* This and the overflow will crop the image */


overflow:hidden;
}
div.newsWrap h1 {
    display:none;
    position:absolute;
    top:0;
    left:0;
    height:40px;


overflow:hidden;
    padding:5px 0 0;
    white-space:nowrap;
}
div.newsWrap h2 {
    display:none;
    position:absolute;


top:60px;
    width:493px;  /* Required for IE6 */
    left:0;
    height:50px;
    overflow:hidden;
    padding:0;
}
div.newsWrap ul{

padding-left:5px;
padding-right:5px;
margin-left:205px;
    margin-top:130px;
width:500px;
}


/* Font styling */
div.newsWrap li,div.newsWrap h2{
    font-family:Arial,Helvetica,sans-serif;
    font-size:12px;
    font-weight:normal;
    line-height:13px;
    color:#000;
}
div.newsWrap h2{
    font-weight:bold;
    text-transform:uppercase;
}
div.newsWrap h1 {
    font-family:impact,Arial,sans-serif;
    font-size:30px;
    letter-spacing:-1px;
    line-height:40px;
    margin:0 auto;
    text-transform:uppercase;
    white-space:nowrap;
}
div.newsWrap li a{
    color:#000;
    padding-left:21px;
    font-weight:bold;


text-decoration:none;
    text-transform:uppercase;
}
div.newsWrap li a:link,div.newsWrap li a:visited {
    text-decoration:none;


color:#000;
}
/*
* This section reveals the strapline, summary and image for the hovered title
* The hover acts as a fallback, the real hover class is set by the selected class
*/
div.newsWrap li a:hover div,div.newsWrap li a.selected

div,div.newsWrap li a:hover h1,div.newsWrap li a.selected h1,div.newsWrap li a:hover   h2,div.newsWrap li a.selected h2 {


display:block;
}
div.newsWrap li a:hover span {
    text-decoration:underline;
}
+2  A: 

You really should fix the page, and then fix the jQuery code. I'd put the <a> tags inside the header tags, around the thumbnail image, and in that <span> (or whatever; it depends on what you want to be clickable). Then change the jQuery code so that it applies the "selected" style to the "newsWrap" div as a whole, and also change the CSS to look the way you want.

If you try to use bad HTML, you're going to find that browsers do weird things.

Pointy
Thanks Pointy, this is what i try to, i am trying to validate the page, i reduced number of total errors from 2400 to 35, but i had to modify core of modules, which produces invalid xhtml... I have still a long way to go but i don't understand the jquery, so i need complete explanation :)
+2  A: 

You can apply the mouseover effects to anything you like, so instead of declaring the effect like this:

jQuery(".newsWrap a").mouseover(function()

Apply the mouseover to another element, for example:

jQuery(".newsWrap h1").mouseover(function()

Or if you prefer:

jQuery(".newsWrap h1 a").mouseover(function()

Just remember to check that all the references inside those functions make sense (or apply to the correct elements).

MODIFIED CODE:

Affects H1 and H2 as requested.

Original:

jQuery(".newsWrap a").mouseover(function(){
    jQuery('.newsWrap a.selected').removeClass('selected');
    jQuery(this).addClass('selected');
});

Modified:

$(".newsWrap h1").mouseover(function() {
    $(".newsWrap h1.selected").removeClass("selected");
    $(this).addClass("selected");
});
$(".newsWrap h2").mouseover(function() {
    $(".newsWrap h2.selected").removeClass("selected");
    $(this).addClass("selected");
});

The first mouseover function affects all H1 elements inside div class .newsWrap, and second mouseover function affects all H2 elements inside div class .newsWrap.

There are more elegant ways to achieve what you're after but I've left it like this to keep things simple. If you want to affect all H1 and H2 tags on the page (not just those inside div class .newsWrap, simply remove the word .newsWrap from everywhere it occurs in the above.

Hope that helps.

Tom
Tom i want to make h1 h2 and title elements clickable, but imagethumb token is not important, so would you mind posting modifications to have this considering i am a noob :)
@idumlupinar, added code as requested. If the solution works for you, don't forget to give me a tick mark :)
Tom
Thank you Tom, i am trying the code, i would appreciate if you could monitor here, in case i may request additions.
Tom, i tried following:jQuery().ready(function() { $(".newsWrap span a:first").addClass('selected'); jQuery(".span a").mouseover(function(){ jQuery('.span a.selected').removeClass('selected'); jQuery(this).addClass('selected'); });});But this time i can't see h1 image, h2 text and div Ia image on left. But titles are working.at css h1 h2 and div iaimage classes have display:none:Would you advice?
If you've applied {display: none;} in your CSS to certain elements, they won't show. Remove that attribute to show them. Apart from that, it's difficult to say. The whole thing seems somewhat messy and I'm not sure what changes you've made overall.
Tom
Tom i removed display:none from those elements. All i want is: if end user mouseover titles (10 title), the h1, h2 contents and image on left side automatically displays:Default title should be the top one with related h1, h2 and image content for it.I want to have h1, h2 and span [TITLE] token clickable, but image on left is not so important.You already deserve the check mark, but i would appreciate if you could solve this issue for me...Thank you.Would you please modify my template, css and jquery for this purpose?
idumlupinar... the code is complicated/messy and needs to be resolved by you. There seems to be one more problem with your CSS unless you've changed it since posting: "a.selected" ... Wherever this occurs, it no longer makes sense because you're not applying the class "selected" to a anymore but instead to h1 and h2 (and span, if you added that jquery). Therefore "a.selected" has to be changed to just ".selected". I think that's the best I can do for you. Good luck.
Tom
Thank you Tom, i will try your suggestions and reply back here.