div在页面重新加载后仍然可见 [英] div remains visible after the page reloads

查看:129
本文介绍了div在页面重新加载后仍然可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我加载我的主页时,我的网站上有语言链接,主页的中间内容div默认为可见,其他中间部分的其他div也加载,但它们已隐藏。当用户点击主页上的链接(语言链接除外)时,会出现该链接的内容div,并且默认链接将隐藏,因此单击链接时只显示并隐藏不重新加载页面的内容div。但是当一个具有一些内容的div是可见的,我点击语言链接它重新加载页面是好的,但我希望div是可见的,在重新加载之前是可见的,并且当它重新加载页面时,它使得主div可见
我的查看代码是

  ************** Main Div *** ************ 

< div id =main-content>
< div id =left-ad>
< img style =margin-bottom:2pxsrc =<?php echo $ template_data ['images_path']?> /left-ad.jpgheight =270pxalt =Ad />
< / div>
< div id =content>
< div id =menu>
< ul id =language_selector>
<?php foreach($ languages as $ lang){?>
< li>
< a href =<?php echo base_url();?> home / box /<?php echo $ template_data ['box_id']?> /<?php echo $ lang [ 'LANGUAGE_NAME']>>
< img src =<?php echo base_url();?> public / default / version01 / images / country_<?php echo $ lang ['language_name']?> .pngwidth = 27height =18border =0/>
< / a>
< / li>
<?php}?>
< / ul>
< / div>
< h2><?php echo $ variables_data [1] ['value']?>< / h2>
< p><?php echo $ variables_data [2] ['value']?>< / p>
< div style =clear:right;>< / div>
< / div>
< div style =clear:left;>< / div>
< div id =download>
< div id =download_arrow>
< img id =download_arrowsrc =<?php echo $ template_data ['images_path']?> /download_arrow.pngalt =免费下载height =36width =43 />
< / div>
< div id =download_button>
< img id =download_buttonsrc =<?php echo $ template_data ['images_path']?> /download_button.pngalt =免费下载height =60width =123 />
< / div>
< div style =clear:both;>< / div>
< / div>

  ***************隐藏的divs ******************** 

<?php foreach($ titles_data as $ title){?>
< div style =display:none; margin:0 10px; font-size:12px; id =content_<?php echo $ title ['idtitles']?>>
< div id =left-ad>
< a href =<?php echo base_url();?> home / download?file =<?php echo $ title ['pdf_path']?>类= download_dialog>
< img style =margin-bottom:2pxsrc =<?php echo base_url();?> import /<?php echo $ title ['image_path']?> height =270pxalt =Ad/>
< / a>< br />
< a href =<?php echo base_url();?> home / download?file =<?php echo $ title ['pdf_path']?>>< img src =<?php echo $ template_data ['images_path']?> /download_button2.png/>< / a>
< / div>
< div id =content>
< div id =menu>
< ul id =language_selector>
<?php foreach($ languages as $ lang){?>
< li>
< a href =<?php echo base_url();?> home / box /<?php echo $ template_data ['box_id']?> /<?php echo $ lang [ 'LANGUAGE_NAME']>? onclick =activate('content_<?php echo $ title ['idtitles']?>')>
< img src =<?php echo base_url();?> public / default / version01 / images / country_<?php echo $ lang ['language_name']?> .pngwidth = 27height =18border =0/>
< / a>
< / li>
<?php}?>
< / ul>
< / div>
< h2><?php echo $ title ['title']?>< / h2>
< p><?php echo $ title ['description']?>< / p>
< div style =clear:right;>< / div>
< / div>
< div style =clear:left;>< / div>
< div id =download>
< div id =download_arrow>
< img id =download_arrowsrc =<?php echo $ template_data ['images_path']?> /download_arrow.pngalt =免费下载height =36width =43 />
< / div>
< div id =download_button>
< img id =download_buttonsrc =<?php echo $ template_data ['images_path']?> /download_button.pngalt =免费下载height =60width =123 />
< / div>
< div style =clear:both;>< / div>
< / div>
< / div>
< div style =clear:both;>< / div>

有些用户建议使用jquery cookie插件,但我不知道如何与codeigniter一起使用。



任何好的帮助来源?



或其他选择?

>

很多预先感谢

解决方案

您可以使用存储在作为一个cookie或创建一个散列链接,以便在页面刷新时打开正确的div。



您可以尝试:


I have languages link on my website when I load my home page the middle content div for the main page is visible by default and some other divs for the middle portion are also loaded but they are hidden. When a user click on a link(other than languages link) on home page the content div for that link appears and the default one hides so clicking on the link only show and hide the content divs not reloading the page. but when a div with some content is visible and i click the language link it reloads the page which is fine but I want the div to be visible that was visible before the reload and currently when it reloads the page it makes the main div visible My view code is

************** Main Div***************

<div id="main-content">
<div id="left-ad">
    <img  style="margin-bottom:2px" src="<?php echo $template_data['images_path'] ?>/left-ad.jpg" height="270px" alt="Ad" />
</div>
<div id="content">
    <div id="menu">                    
        <ul id="language_selector">
            <?php foreach ($languages as $lang) { ?> 
                <li>
                    <a href="<?php echo base_url(); ?>home/box/<?php echo $template_data['box_id']?>/<?php echo $lang['language_name']?>">
                        <img src="<?php echo base_url(); ?>public/default/version01/images/country_<?php echo $lang['language_name'] ?>.png" width="27" height="18" border="0" />
                    </a>
                </li>
            <?php } ?> 
        </ul>                       
    </div>
    <h2><?php echo $variables_data[1]['value'] ?></h2>
    <p><?php echo $variables_data[2]['value'] ?></p>
    <div style="clear:right;"></div>
</div>
<div style="clear:left;"></div>             
<div id="download">
    <div id="download_arrow">
        <img id="download_arrow" src="<?php echo $template_data['images_path'] ?>/download_arrow.png" alt="Free Download" height="36" width="43" />
    </div>
    <div id="download_button">
        <img id="download_button" src="<?php echo $template_data['images_path'] ?>/download_button.png" alt="Free Download" height="60" width="123" />
    </div>
    <div style="clear:both;"></div>
</div>

***************Hidden divs********************

<?php foreach ($titles_data as $title) { ?>
<div style="display:none; margin: 0 10px; font-size:12px;" id="content_<?php echo $title['idtitles'] ?>">
    <div id="left-ad">
        <a href="<?php echo base_url(); ?>home/download?file=<?php echo $title['pdf_path'] ?>" class='download_dialog'>
            <img  style="margin-bottom:2px" src="<?php echo base_url(); ?>import/<?php echo $title['image_path'] ?>" height="270px" alt="Ad" />
        </a><br />
        <a href="<?php echo base_url(); ?>home/download?file=<?php echo $title['pdf_path'] ?>"><img src="<?php echo $template_data['images_path'] ?>/download_button2.png"/></a> 
    </div>
    <div id="content">
        <div id="menu">                    
            <ul id="language_selector">
                <?php foreach ($languages as $lang) { ?>
                    <li>
                        <a href="<?php echo base_url(); ?>home/box/<?php echo $template_data['box_id']?>/<?php echo $lang['language_name']?>" onclick="activate('content_<?php echo $title['idtitles'] ?>')">
                            <img src="<?php echo base_url(); ?>public/default/version01/images/country_<?php echo $lang['language_name'] ?>.png" width="27" height="18" border="0" />
                        </a>
                    </li>
                <?php } ?>
            </ul>                       
        </div>
        <h2><?php echo $title['title'] ?></h2>
        <p><?php echo $title['description'] ?></p>
        <div style="clear:right;"></div>
    </div>
    <div style="clear:left;"></div>             
    <div id="download">
        <div id="download_arrow">
            <img id="download_arrow" src="<?php echo $template_data['images_path'] ?>/download_arrow.png" alt="Free Download" height="36" width="43" />
        </div>
        <div id="download_button">
            <img id="download_button" src="<?php echo $template_data['images_path'] ?>/download_button.png" alt="Free Download" height="60" width="123" />
        </div>
        <div style="clear:both;"></div>
    </div>
</div>
<div style="clear:both;"></div>

Some users suggested to use jquery cookie plugin but I dont know how to use it with codeigniter.

Any good source of help ?

or any other alternative ?

Many Thanks in advance

解决方案

You could either use a session variable stored in as a cookie or create a hash link to open the correct div when the page refreshes.

You could try:

这篇关于div在页面重新加载后仍然可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆