2014-05-13 4 views
1

사용자의 입력을 기반으로 일부 매개 변수를 포함하는 URL을 생성하고 싶습니다. 앵커가 있고 addMouseDownHandler 또는 addClickHandler를 사용하여 앵커의 링크를 변경할 수 있습니다. 문제는이 앵커를 두 번 클릭 한 후에 만 ​​변경된 링크가 활성화되고 앵커를 처음 클릭 할 때 지정된 URL이 활성화된다는 것입니다.href를 변경하기 전에 앵커가 URL을 활성화합니다.

function onMouseDownAnchor(e) 
{ 
Logger.log(JSON.stringify(e));// you can see the source parameter in e that returns the widgets ID of the button you clicked to call the handler 

    var app = UiApp.getActiveApplication(); 

    var btnAnchor = app.getElementById('btnAnchor'); 
    var newLink = 'http://www.google.com'; 
    btnAnchor.setHref(newLink) 
    Logger.log('onMouseDownAnchor'); 

    return app; 
} 

앵커가 클릭 할 때 앵커가 활성화되기 전에 앵커의 href를 어떻게 변경할 수 있습니까?

답변

1

해결책을 직접 찾았습니다. 대신

onMouseDownAnchor 

를 사용하는 나는 단지

var anchor = myApp.createAnchor("", siteUrl) 
        .setId('btnAnchor').setName('bntAnchor') 
        .setHeight(heightButton).setWidth(widthButton)    
        .setStyleAttribute('backgroundImage', 'url(' + picButton + ')'); 

    var onMouseOverAnchor = myApp.createServerHandler('onMouseOverAnchor'); 
    anchor.addMouseOverHandler(onMouseOverAnchor); // This will change the href of the anchor 

이되어 있어야합니다, 물론,
onMouseOverAnchor 

그렇게 작업 코드는

function onMouseOverAnchor(e) 
{ 
Logger.log(JSON.stringify(e));// you can see the source parameter in e that returns the widgets ID of the button you clicked to call the handler 

    var app = UiApp.getActiveApplication(); 

    var btnAnchor = app.getElementById('btnAnchor'); 
    var newLink = 'http://www.google.com'; 
    btnAnchor.setHref(newLink) 
    Logger.log('onMouseOverAnchor'); 

    return app; 
} 

된다 사용해야하고 만들어진 doGet 함수에서

관련 문제