0

i googled and searched here to but unable to figure it out my script is not working

i'm loading a html file using .load function file loaded successfully but javascirpt in is not working when i view that file in browser all works..

below function is loading html file

function loadPage(page, pageElement) {

$(pageElement).load('pages/page' + page + '.html');

//loadRegions(page, pageElement);}

this is the function in ajax loaded html file

addLoadEvent(load1);

script is generated by pdftohtml script that generate canvas... i can't attach it to any event like click .. can it work as it is...

pdftohtml generate script

function adjustCharSpacing(el,actualWidth) {
    var rawWidth=el.offsetWidth;
    if(actualWidth>20 & rawWidth!=actualWidth && actualWidth>rawWidth){
        var spacing= 0;
        var s=spacing+'px';
        el.style.charSpacing = s;
        rawWidth=el.offsetWidth;

        var diff=rawWidth-actualWidth;
        if(diff20 && actualWidth>rawWidth && rawWidth!=actualWidth & el.textContent.search(' ') > -1){
        var spacing= 0;
        var s=spacing+'px';
        el.style.wordSpacing = s;
        rawWidth=el.offsetWidth;

        var diff=rawWidth-actualWidth;
        if(diff12 & rawWidth>5 & rawWidth!=actualWidth){
        if(rawWidth>actualWidth){
            while (rawWidth>actualWidth & lastRawWidth!=rawWidth){
                pixelSize--;
                el.style.fontSize = pixelSize+'px';
                lastRawWidth=rawWidth;
                rawWidth=el.offsetWidth;
            }
            var lastDiff=lastRawWidth-actualWidth;
            var nextDiff=actualWidth-rawWidth;
            if(lastDiff5)
            el.style.fontSize = pixelSize+'px';
        else
            el.style.fontSize = rawFontSize+'px';

        if(pixelSize!=el.style.fontSize){
            adjustCharSpacing(el,actualWidth);
            adjustWordSpacing(el,actualWidth);
        }

    }
}

var pdf;
function M(a,b){pdf.moveTo(a,b);}
function L(a,b){pdf.lineTo(a,b);}
function C(a,b,c,d,e,f){pdf.bezierCurveTo(a,b,c,d,e,f);}
function Q(a,b,c,d){pdf.quadraticCurveTo(a,b,c,d);}
function BP(){pdf.beginPath();}
function CP(){pdf.closePath();}
function LW(a){pdf.lineWidth=a;}
function LC(a){pdf.lineCap=a;}
function LJ(a){pdf.lineJoin=a;}
function ML(a){pdf.miterLimit=a;}
function SS(a){pdf.strokeStyle=a;}
function ST(){pdf.stroke();}
function GA(a){pdf.globalAlpha=a;}
function FS(a){pdf.fillStyle=a;}
function FI(){pdf.fill();}
function CL(){pdf.clip();}
function SV(){pdf.save();}
function RS(){pdf.restore();}

var loaded1 = false;
var assetsLoaded1 = 0;
var assetCount1 = 20;
var images1 = new Array();
var imageCount1 = 20;
function load1(){
    if (!loaded1) {
        loaded1=true;
        document.getElementsByClassName("l1")[0].innerHTML = "Loading Assets...";
        for (var i = 1; i 

4

1 回答 1

1

使用load()方法的回调函数:

$(pageElement).load('pages/page' + page + '.html',function(){
    $('#myCanvas').on('click',function(){alert('canvas clicked');});
});

或者使用委托,例如:

$(document.body).on('click','myCanvas', function(){
    alert('canvas clicked');
});
于 2013-07-07T12:26:00.393 回答