// ссылка на страницу, с которой отправляется запрос
var loc = document.location.hostname;
if (document.location.pathname) loc += document.location.pathname;
else if ('/'==loc.substring(loc.length-1)) loc = loc.substring(0, loc.length-1)
// функция получает значение name из URL или переданного параметра url
function getURLParameter(name, url) {
name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');
var results = new RegExp('[?&]'+name+'=?([^&#]*)').exec(url || window.location.href);
return results === null ? null : results[1] || true;
}
// функция создаёт объект XMLHTTPRequest
function getXmlHttp(){
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function send2crm(to, name, phone) {
var req = getXmlHttp();
var params = 'url=' + loc +
'&utm_source=' + getURLParameter('utm_source') +
'&utm_term=' + getURLParameter('utm_term') +
'&utm_medium=' + getURLParameter('utm_medium') +
'&utm_content=' + getURLParameter('utm_content') +
'&utm_campaign=' + getURLParameter('utm_campaign') +
'&name=' + name +
'&phone=' + phone;
req.open("POST", to, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(params);
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.