Visualizzazione dei risultati da 1 a 7 su 7

Discussione: problema behaviour

  1. #1

    problema behaviour

    sto cercando di risolvere il problema di IE con le png trasparenti, ma qualcosa non funziona. Il codice è

    <html>
    <head>
    <style type="text/css">
    div {behaviour: url("iepngfix.htc")}
    </style>
    </head>
    <body>
    <div >pippo</div>
    </body>
    </html>

    nel file "iepngfix.htc" ho inserito un alert che non viene effettuato quindi penso che lo script non venga proprio eseguito..

    la pagina html e il "iepngfix.htc"si trovano nella stessa cartella...

  2. #2
    Frontend samurai L'avatar di fcaldera
    Registrato dal
    Feb 2003
    Messaggi
    12,924
    si scrive behavior (senza 'u')
    se non funziona ancora posta il contenuto del file iepngfix.htc
    Vuoi aiutare la riforestazione responsabile?

    Iscriviti a Ecologi e inizia a rimuovere la tua impronta ecologica (30 alberi extra usando il referral)

  3. #3
    <public:component>
    <public:attach event="onpropertychange" onevent="iePNGFix(0)" />

    <script type="text/javascript">

    alert('This works!');
    // IE5.5+ PNG Alpha Fix v1.0
    // (c) 2004-2008 Angus Turnbull http://www.twinhelix.com

    // This is licensed under the GNU LGPL, version 2.1 or later.
    // For details, see: http://creativecommons.org/licenses/LGPL/2.1/


    // This must be a path to a blank image, relative to the HTML document(s).
    // In production use I suggest '/images/blank.gif' or similar. That's all!
    if (typeof blankImg == 'undefined') var blankImg = 'blank.gif';


    function filt(s, b)
    {
    var f = 'DXImageTransform.Microsoft.AlphaImageLoader';
    var sM = (currentStyle.backgroundRepeat == 'no-repeat') ? 'crop' : 'scale';
    s = (s || '').replace(/\(/g, '%28').replace(/\)/g, '%29');

    if (s && !(/IMG|INPUT/.test(nodeName) && !b) &&
    currentStyle.width == 'auto' && currentStyle.height == 'auto')
    {
    style.width = offsetWidth + 'px';
    style.height = clientHeight + 'px';
    if (currentStyle.display == 'inline') style.display = 'inline-block';
    }

    if (filters[f])
    {
    filters[f].enabled = s ? true : false;
    if (s) with (filters[f]) { src = s }
    }
    else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="' + sM + '")';
    }

    function iePNGFix(init)
    {
    if (!/MSIE (5\.5|6)/.test(navigator.userAgent) || typeof filters == 'unknown') return;
    var evt = init ? { propertyName: 'src,background' } : event;
    var isSrc = /src/.test(evt.propertyName);
    var isBg = /background/.test(evt.propertyName);
    var isClass = !init &&
    ((this.className != this._png_class) && (this.className || this._png_class));
    if (!(isSrc || isBg || isClass)) return;
    this._png_class = this.className;
    var blank = blankImg.match(/([^\/]+)$/)[1];

    // Required for Whatever:hover support - erase any set BG if className changes.
    if (isClass && ((style.backgroundImage.indexOf('url(') == -1) ||
    (style.backgroundImage.indexOf(blank) > -1)))
    {
    setTimeout(function() { this.style.backgroundImage = '' }, 0);
    return;
    }

    if (isSrc && this.src && /IMG|INPUT/.test(nodeName))
    {
    if ((/\.png/i).test(src))
    {
    filt(src, 1);
    src = blankImg;
    }
    else if (src.indexOf(blank) == -1) filt();
    }

    var bgSrc = currentStyle.backgroundImage || style.backgroundImage;
    if ((bgSrc + this.src).indexOf(blank) == -1)
    {
    var bgPNG = bgSrc.match(/^url[("']+(.*\.png[^\)"']*)[\)"']+[^\)]*$/i);

    if (bgPNG)
    {
    style.backgroundImage = 'url("' + blankImg + '")';
    filt(bgPNG[1], 0);
    // Unclickable elements inside PNG backgrounds.
    var tags = ['a', 'input', 'select', 'textarea', 'iframe', 'object'],
    t = tags.length, tFix = [];
    while (t--)
    {
    var elms = all.tags(tags[t]), e = elms.length;
    while (e--) tFix.push(elms[e]);
    }
    var t = tFix.length;
    if (t && (/relative|absolute/i).test(currentStyle.position))
    alert('IEPNGFix: Children of positioned element are unclickable:\n\n<' +
    nodeName + (id && ' id=' + id) + '>');
    while (t--)
    if (!(/relative|absolute/i).test(tFix[t].currentStyle.position))
    tFix[t].style.position = 'relative';
    }
    else filt();
    }
    }

    iePNGFix(1);

    </script>
    </public:component>

  4. #4
    per semplificare ho provato

    <html>
    <head>
    <style type="text/css">
    h1 { behavior: url(behave.htc) }
    </style>
    </head>

    <body>
    <h1>Mouse over me!!!</h1>
    </body>
    </html>


    con il file "behave.htc"

    <attach for="element" event="onmouseover" handler="hig_lite" />
    <attach for="element" event="onmouseout" handler="low_lite" />

    <script type="text/javascript">
    function hig_lite()
    {
    element.style.color='red';
    }

    function low_lite()
    {
    element.style.color='blue';
    }
    </script>


    non funziona neanche questo...
    non so più cosa fare

  5. #5
    Frontend samurai L'avatar di fcaldera
    Registrato dal
    Feb 2003
    Messaggi
    12,924
    codice:
    <html>
    <head>
    <style type="text/css">
    h1 { behavior: url("behave.htc") }
    </style>
    </head>
    
    <body>
    <h1>Mouse over me!!!</h1>
    </body>
    </html>
    file "behave.htc"

    codice:
    <public:component>
    <public:attach event="oncontentready" />
    
       <script type="text/javascript">
    
          element.onmouseover = function() {
            this.style.color='red';
          };
    
          element.onmouseout = function() {
             this.style.color='blue'
          };
    
       </script>
    </public:component>

    per le png trasparenti se hai pazienza credo uscirà un articolo su html.it...


    Ciao


    edit: l'ho modificato, riprovalo.
    Vuoi aiutare la riforestazione responsabile?

    Iscriviti a Ecologi e inizia a rimuovere la tua impronta ecologica (30 alberi extra usando il referral)

  6. #6
    non funziona neanche così... boh.
    Non è un problema di browser perchè lo stesso codice pubblicato dal w3 school mi funziona

  7. #7
    Frontend samurai L'avatar di fcaldera
    Registrato dal
    Feb 2003
    Messaggi
    12,924
    Originariamente inviato da degno
    non funziona neanche così... boh.
    Non è un problema di browser perchè lo stesso codice pubblicato dal w3 school mi funziona
    il codice che ti ho postato l'ho provato su IE6 di sistema (non emulato o standalone)
    quindi o il tuo browser non esegue quel behavior
    o ci sono errori altrove
    Vuoi aiutare la riforestazione responsabile?

    Iscriviti a Ecologi e inizia a rimuovere la tua impronta ecologica (30 alberi extra usando il referral)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.