通过嵌入式svg对象&#39;,我指的是一个svg文件的html <!DOCTYPE html>
<html lang="en">
<head>
<script>
function setCookie(cname,cvalue,exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname+"="+cvalue+"; "+expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie() {
var user=getCookie("username");
if (user != "") {
document.getElementById("welcome").innerHTML = username;
} else {
user = prompt("Please enter your name:","");
if (user != "" && user != null) {
setCookie("username", user, 30);
}
}
}
</script>
</head>
<body onload="checkCookie()">
<p id="welcome"> <!-- want "Welcome again" + username message here --> </p>
</body>
</html>
标记,例如:
<object>
显示问题的示例:https://jsfiddle.net/d8jx3ru7/
即使<object id="svgobject"
data="https://upload.wikimedia.org/wikipedia/commons/6/6b/Bitmap_VS_SVG.svg"
type="image/svg+xml" title="I want to see this title!"></object>
支持title属性,如果它是SVG图像,它似乎没有效果。
我可以在SVG文件中放置一个静态标题,但如果需要动态确定标题怎么办?有没有办法做到这一点?
答案 0 :(得分:0)
使用jQuery,你可以
$("#svgobject").attr('title', 'Whatever you want');
希望它有所帮助!