I am new to coding so need some help please.
I have set up a url page where the images are changing dynamically using the following code. However when I link to this from my Outlook email signature, it isn't returning that image, just a broken link. Do I need to add javascript to get it to return the image when called please?:
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=0.1">
<title>dynamic email</title>
</head>
<body style="margin: 0px; background: #0e0e0e; height: 100%">
<img id="Projects" style="display: block;-webkit-user-select: none;margin: auto;background-color: hsl(0, 0%, 90%);" src="https://www.mywebsite.com/assets/email-assets/image1.png" width="547" height="184">
<script>var imageSources = ["https://www.mywebsite.com/assets/email-assets/image2.png", "https://www.mywebsite.com/assets/email-assets/image3.png", "https://www.mywebsite.com/assets/email-assets/image4.png", "https://www.mywebsite.com/assets/email-assets/image5.png", "https://www.mywebsite.com/assets/email-assets/image6.png", "https://www.mywebsite.com/assets/email-assets/image7.png"]
var index = 0;
setInterval(function(){
if (index === imageSources.length) {
index = 0;
}
document.getElementById("Projects").src = imageSources[index];
index ;
}, 1000);
</script>
</body>
</html>
CodePudding user response:
Outlook does not run any scripts or submit HTML forms for security reasons.
CodePudding user response:
Most email clients will not allow for javascript inside the email body.
To help protect you from viruses that might be contained in HTML-format and RTF-format messages, both scripts and ActiveX controls contained in these kinds of messages are deactivated automatically, regardless of the security zone setting. This is because Outlook places all incoming messages in the Restricted Sites security zone by default. The default setting for the Restricted Sites zone is High. This disables automatic scripting and prevents ActiveX controls from opening without permission.
Changing the zone setting to something other than the default is not recommended.
If you need to run the script on an individual message when the security zone is set to Restricted Sites
, you can work around the default protection by following these steps:
- Open the message.
- On the
View
menu, clickView
inInternet Zone
. - Click
Yes
when you are prompted about running the script.
You can now run the script.