×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

@

Thanks. Here is my source code.

本文发表在 rolia.net 枫下论坛For JS part, the code is here, which triggered by click on the div
function showImage(div)
{
var firstElement, secondElement;
var workplace, stepbox;
var todayDate, intDate, intTodayDate, nextDay;
firstElement = div.getElementsByTagName('span')[0];
secondElement = div.getElementsByTagName('span')[1];
todayDate = new Date();
intTodayDate = parseInt(todayDate.getDate());
intDate = parseInt(firstElement.innerHTML)
nextDay = new Date(todayDate.getYear(), todayDate.getMonth(), 8);
if (firstElement.innerHTML != "" )
{
var i, j;
i = document.getElementById(div.id).style.top ;
j = document.getElementById(div.id).style.left ;
workplace = document.getElementById('workplace');
workplace.style.position = "absolute";
workplace.style.top = i;
workplace.style.left = j;
//alert(workplace.firstChild.firstChild.id);
stepbox = document.getElementById('txtSteps');
stepbox.value = secondElement.innerHTML;

//txtSteps.innerText = secondElement.innerText;
workplace.style.visibility = 'visible';
stepbox.focus();
var lblname;
lblname = document.getElementById('txtlblName');
lblname.value = div.id;
}
}

in my vb.net code, under certain condition:

If DateDiff("d", thisDate, Today()) > 30 or DateDiff("d", thisDate, Today()) < 0 Then
dayDiv = page.FindControl("div" & Session("intWeekFirst")+j)
dayDiv.disabled = true
End If

Hope this is clear enough. No matter, thank you guys so much for trying to help me out. I really appreciate it.更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 专业知识杂谈 / Mia小妹初次报到, 先向各位请安! 希望能够得到大家的支持和帮助。
    我现有一个.net方面的问题,恳请高手给与指点, 先谢谢了!

    我有一个div, 在javascript 里有关于此div的点击的script, 在有些情况下,我要对此功能disable, 所以我的语句是:
    dayDiv.Disabled = true
    此语句在internet explore works just fine, but the Firefox just does not work at all, do I need add something else for Firefox? Thanks in advance.
    • 这个明显不是.net 问题
      • Thanks for your reply. This sentence: dayDiv.Disabled = true is in vb.net, if you think it is not about .net, what I can make it disable(does not allow to click)? Thanks a lot.
        • Whatever IE can torelate doesn't imply firefox can as well. As I said, javascript is case sensitive. You have a flaw in your code.
          • I am not quite get it. This is the vb.net code in my vb.net script, it does not have anything about the javascript, please give more detail explanation. Thanks.
    • javascript is case sensitive.
      • Yes, I know it. The thing is my vb.net code does not work in Firefox, I know you sounds weired. So, I need help. Thanks a lot.
        • as I said over over again "case sensitive". Try "disabled". Javascript is very lousy and sensitive. A small flaw can cost you couple of hours to debug.
          • Maybe I did not explain it clearly, the code of dayDiv.Disabled = true is vb.net code, not javascript, the this code just work fine in IE, but firefox does not work at all, it sounds weired. So, I need help. Thanks.
            • 我非常了解你的问题了。让你去试试disabled=true,你就先去试试么。在我看来,disable一个div,怎么看都是javascript。IE能够容忍的script error,firefox不一定能够容忍。
              • Thanks. I have tried it, but does not work neither. Thanks a lot for your patient.
        • by the way, do you have "javascript console" in firefox? If you do, open that console, it will telll you which javascript is wrong in which line number.
          • Let me explain it again. Thanks.
            Make it a little bit clear, I have a div, when I click it, it has a js for click event, which shows an image, but on certain situation, I do not want to disable click event, so I give a vb.net code dayDiv.disabled = true, this code(vb.net) does not work in Firefox. Did I do something wrong? or there is something else I can implenment this?
    • IE is much forgiven as far as scripting concerned.
      When you tell a div disabled, it disable all children within it. But, if you want your function to work cross browsers, you have to get the specific object down the tree.
      • Thanks. I know that, my purpose is to disable all the contents in the div, which works in IE, but firefox does not, is there something else I can do?
        • Try some other ways
          for example:

          theDiv.style.display=’none’

          or

          theDiv.onclick = ;

          or

          for loop to disable each object

          or

          x = event.sourceElement
          if x = something then do someothering()
    • 把你的source code贴出来,大家看看不就明白了?
      • Thanks. Here is my source code.
        本文发表在 rolia.net 枫下论坛For JS part, the code is here, which triggered by click on the div
        function showImage(div)
        {
        var firstElement, secondElement;
        var workplace, stepbox;
        var todayDate, intDate, intTodayDate, nextDay;
        firstElement = div.getElementsByTagName('span')[0];
        secondElement = div.getElementsByTagName('span')[1];
        todayDate = new Date();
        intTodayDate = parseInt(todayDate.getDate());
        intDate = parseInt(firstElement.innerHTML)
        nextDay = new Date(todayDate.getYear(), todayDate.getMonth(), 8);
        if (firstElement.innerHTML != "" )
        {
        var i, j;
        i = document.getElementById(div.id).style.top ;
        j = document.getElementById(div.id).style.left ;
        workplace = document.getElementById('workplace');
        workplace.style.position = "absolute";
        workplace.style.top = i;
        workplace.style.left = j;
        //alert(workplace.firstChild.firstChild.id);
        stepbox = document.getElementById('txtSteps');
        stepbox.value = secondElement.innerHTML;

        //txtSteps.innerText = secondElement.innerText;
        workplace.style.visibility = 'visible';
        stepbox.focus();
        var lblname;
        lblname = document.getElementById('txtlblName');
        lblname.value = div.id;
        }
        }

        in my vb.net code, under certain condition:

        If DateDiff("d", thisDate, Today()) > 30 or DateDiff("d", thisDate, Today()) < 0 Then
        dayDiv = page.FindControl("div" & Session("intWeekFirst")+j)
        dayDiv.disabled = true
        End If

        Hope this is clear enough. No matter, thank you guys so much for trying to help me out. I really appreciate it.更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • You can define a var. if the browser is IE, set the value of var to your div. If it is netscape-firefox, set the value to the contents of the div. Then you can disable the var in you specified condition
      • Please see my source code. Thanks.
        • you can write JS code as i mentioned. For netscape-firefox, div as a whole cannot be 'disabled'. you have to disable its elements
          • The thing is, I like to make it happen in vb.net, the div include 3 labels, how could I disable label in vb.net? Thanks.
            • In that case, you can write JS code within your vb.net code (see inside), and disable your elements in the JS.
              something like this:

              Dim myJS As StringBuilder = New StringBuilder()
              myJS.Append("<script language='Javascript'>")
              ....
              myJS.Append("</script>")
              • Thank you so much for this reply. I tried to make it in JS, looks like it works fine. Thanks a lot for everyone trying to help me. I do appreciate it. And hope I can get answer for another question.