Add a sns web's share JavaScript into wt app
Added by Zhimin Song almost 13 years ago
hey all:
I have a problem about "Add a sns web's share JavaScript into wt app", it is easy when using pure html, like the following:
<html>
<body>
<script type="text/javascript" src="http://widget.renren.com/js/rrshare.js"></script>
<a name="xn_share" onclick="shareClick()" type="icon" href="javascript:;"></a>
<script type="text/javascript">
function shareClick() {
var rrShareParam = {
resourceUrl : '',
pic : '',
title : '',
description : ''
};
rrShareOnclick(rrShareParam);
}
</script>
</html>
</body>
In wt app, I modified that like this:
wApp->require("http://widget.renren.com/js/rrshare.js");
WAnchor *rrshare = new WAnchor(layout_);
doJavaScript(rrshare->jsRef() + ".name=\"xn_share\"; " +
rrshare->jsRef() + ".type=\"icon\"; " +
rrshare->jsRef() + ".href=\"javascript:;\"");
JSlot shareClick;
shareClick.setJavaScript
("{"
"var rrShareParam = {"
"resourceUrl : '',"
"pic : '',"
"title : '',"
"description : ''};"
"rrShareOnclick(rrShareParam);}");
rrshare->clicked().connect(shareClick);
But this does not work, or it does not show the WAnchor(should be a icon for share), in the chrome debug, I found the WAnchor like below:
<a id="ompf4ev" href="javascript:;" class="Wt-rr" name="xn_share" type="icon"></a>
so I think the remote js did not really work for the anchor, right? Then I added a clause :
rrshare->setText("rrshare");
The anchor showed with "rrshare"(not the right icon), but still not react the shareClick JSlot:-(
Thanks for any help in advance!
Regards
Zhimin
Replies (1)
RE: Add a sns web's share JavaScript into wt app - Added by Zhimin Song almost 13 years ago
Today, I replaced the WAnchor
WAnchor *rrshare = new WAnchor(layout_);
doJavaScript(rrshare->jsRef() + ".name=\"xn_share\"; " +
rrshare->jsRef() + ".type=\"icon\"; " +
rrshare->jsRef() + ".href=\"javascript:;\"");
with
WText("<a name="xn_share" onclick="shareClick()" type="icon" href="javascript:;">*SHARE*</a>");
and add "function(o, e)" to the shareClick.setJavaScript(), It works!:-)
but still got the style from remote js lib, just SHARE:-(
BR
Zhimin