Skip to content

Commit 37bb0db

Browse files
author
shengyonggen
committed
IE8以下element_content没数据的问题
1 parent e0f365d commit 37bb0db

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

sensorsdata.amd.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sensorsdata.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sdk.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,13 +898,18 @@ _.getEleInfo = function(obj){
898898
props.$element_target_url = target.getAttribute('href');
899899

900900
// 获取内容
901+
902+
var textContent = '';
901903
if (target.textContent) {
902-
var textContent = _.trim(target.textContent);
903-
if (textContent) {
904-
textContent = textContent.replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ').substring(0, 255);
905-
}
906-
props.$element_content = textContent || '';
904+
textContent = _.trim(target.textContent);
905+
}else if(target.innerText){
906+
textContent = _.trim(target.innerText);
907+
}
908+
if (textContent) {
909+
textContent = textContent.replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ').substring(0, 255);
907910
}
911+
props.$element_content = textContent || '';
912+
908913
// 针对inut默认只采集button和submit非名感的词汇。可以自定义(银联提)
909914
if(tagName === 'input'){
910915
if(target.type === 'button' || target.type === 'submit'){
@@ -924,7 +929,6 @@ _.getEleInfo = function(obj){
924929

925930
};
926931

927-
928932
// _.localStorage
929933
_.localStorage = {
930934
get: function(name) {

src/sensorsdata.full.amd.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,13 +1020,18 @@ _.getEleInfo = function(obj){
10201020
props.$element_target_url = target.getAttribute('href');
10211021

10221022
// 获取内容
1023+
1024+
var textContent = '';
10231025
if (target.textContent) {
1024-
var textContent = _.trim(target.textContent);
1025-
if (textContent) {
1026-
textContent = textContent.replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ').substring(0, 255);
1027-
}
1028-
props.$element_content = textContent || '';
1026+
textContent = _.trim(target.textContent);
1027+
}else if(target.innerText){
1028+
textContent = _.trim(target.innerText);
1029+
}
1030+
if (textContent) {
1031+
textContent = textContent.replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ').substring(0, 255);
10291032
}
1033+
props.$element_content = textContent || '';
1034+
10301035
// 针对inut默认只采集button和submit非名感的词汇。可以自定义(银联提)
10311036
if(tagName === 'input'){
10321037
if(target.type === 'button' || target.type === 'submit'){
@@ -1046,7 +1051,6 @@ _.getEleInfo = function(obj){
10461051

10471052
};
10481053

1049-
10501054
// _.localStorage
10511055
_.localStorage = {
10521056
get: function(name) {

src/sensorsdata.full.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,13 +1017,18 @@ _.getEleInfo = function(obj){
10171017
props.$element_target_url = target.getAttribute('href');
10181018

10191019
// 获取内容
1020+
1021+
var textContent = '';
10201022
if (target.textContent) {
1021-
var textContent = _.trim(target.textContent);
1022-
if (textContent) {
1023-
textContent = textContent.replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ').substring(0, 255);
1024-
}
1025-
props.$element_content = textContent || '';
1023+
textContent = _.trim(target.textContent);
1024+
}else if(target.innerText){
1025+
textContent = _.trim(target.innerText);
1026+
}
1027+
if (textContent) {
1028+
textContent = textContent.replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ').substring(0, 255);
10261029
}
1030+
props.$element_content = textContent || '';
1031+
10271032
// 针对inut默认只采集button和submit非名感的词汇。可以自定义(银联提)
10281033
if(tagName === 'input'){
10291034
if(target.type === 'button' || target.type === 'submit'){
@@ -1043,7 +1048,6 @@ _.getEleInfo = function(obj){
10431048

10441049
};
10451050

1046-
10471051
// _.localStorage
10481052
_.localStorage = {
10491053
get: function(name) {

vtrack.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)