不同语言HTML注入的不同横幅 [英] Different banner for different language HTML injection

查看:109
本文介绍了不同语言HTML注入的不同横幅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在网站上实施横幅广告。这必须通过html注入发生,该网站是一个rigdit预制网站,所以我无法更改代码。我只能在头部,身体和足部真正的注射中捏造东西。



横幅必须为每种语言显示不同的图像,如英语,法语......

横幅点击时有链接在网站上的另一个页面上。

所以我想我必须说img scr = URL并且该URL是基于交换机的变量,或者是否基于该语言的变量。



我想我可以通过这种方式确定页面的语言

< body class =content-flexipage-pagedata- url-root =/data-url-home =/ fr-be />

fr-be是网站adres的一部分:https:// site / fr-be /。其他选项如/ en-be /代表英语。



我不知道怎么写这个。我曾尝试使用javascript和

I need to implement a banner in a website. This had to happen with html injection, the website is a rigdit pre-made site so I can't change the code. I can only impliment stuff in th head, body and foot true injection.

The banner has to show a different image for every language like English, French...
The banner has a link when you click on to another page on the site.
So I guess I have to say that the img scr = URL and that URL is variable based on an switch or if then else based on the language.

I think I can determine the language of the page this way
<body class="content-flexipage-page" data-url-root="/" data-url-home="/fr-be/">
fr-be is a part of the site adres : https://site/fr-be/ . Other opstions like /en-be/ stand for English .

I have no idea how to write this. I have tried to use javascript and

等..

我在CSS上有很多信息,但我不知道这一点。



这是当前的横幅代码,它有效:

etc..
I foudna lot of info on CSS , but I don't know this.

This is the current banner code , it works :
href="URL to target link"
<img src="URL to image" 

 width="50%"  height="50%" align="middle" alt="Text if banner does not load"  width="125xp" height=125px"/>





我尝试了什么:





What I have tried:

<style>
    .Link{

if (data-url-home:"/nl-be/"){
	Link="URL1";
}
else if (data-url-home="/fr-be/"){ 
Link="URL2";
} else { Link="";}

}
</style></div>

推荐答案

I made it work . not elegant. 


<a href="Target URL">
<p id="demo"></p>
 <center><img id="MyImg">
 width="50%"  height="50%" align="middle" alt="ALTERNATIEVE TEKST ALS DE IMAGE NIET LAAD"  width="125xp" height=125px"  /><center>
<script>

var Link =window.location.href;
var image = document.getElementById("MyImg");
document.getElementById("demo").innerHTML = Link;

if (Link=="URL home dutch "){
	 image.src="url1" ;
}
else if (Link=="URLhome French"){ 
    image.src="url2" ;
}
else {
image.scr = "";
}

</script>

</center></img></center></a>


我想我到了某个地方,但它仍然无法工作



boduy有class:content-flexipage-page和data- url-home作为主页URL。这是我可以确定页面语言的唯一方法



I think I'm getting somewhere, but it still not working

The boduy has class : content-flexipage-page and a data-url-home as home page URL . this is the only way I can determin the page language

a[target] {
   src="#";
}

<a href=" url when clicked on" target="#">
 <center><img>
 width="50%"  height="50%" align="middle" alt="ALTERNATIEVE TEKST ALS DE IMAGE NIET LAAD"  width="125xp" height=125px"  /><center>
</center></img></center></a>
 

<script type="text/javascript">
var Link =document.getElementsByClassName(content-flexipage-page).data-url-home;

if (Link="/nl-be/"){
	    document.querySelector("a[target]").img.scr = "URL1" ;
}
else if (Link="/fr-be/"){ 
    document.querySelector("a[target]").img.scr = "URL2" ;
}
else {
document.querySelector("a[target]").img.scr = "#";

}
</script>


这篇关于不同语言HTML注入的不同横幅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆