I'm hoping the above title is accurate to what I need to do. I've been Googling my face off and nothing seems to be working.
Here is a snippet of my code...
var options = {
campaigns: {
'hydraulic_repair': {
phone: '(555) 555-5555',
myform: '<div class="adwords-switched"><iframe src="http://www.mywebsite.com/contact-form-google-sfp/" allowtransparency="true" width="100%" height="725px" type="text/html" scrolling="no" frameborder="0" style="border:0"></iframe></div>'
}
}
};
I now need to add some variables into the mix. It works fine when I hard code the variables like this:
http://www.mywebsite.com/contact-form-google-sfp/?keyword=HELLO&adgroup=WORLD
however the keyword and adgroup are going to be dynamic, and when I try to enter variables into the string, it breaks my code. I'm not sure why the "+" concatenation isn't working, is there a different method to add variables in that I'm missing?
var mykeyword = 'HELLO';
var myadgroup = 'WORLD';
var options = {
campaigns: {
'hydraulic_repair': {
phone: '(555) 555-5555',
myform: '<div class="adwords-switched"><iframe src="http://www.mywebsite.com/contact-form-google-sfp/?keyword='+mykeyword+'&adgroup='+myadgroup+'" allowtransparency="true" width="100%" height="725px" type="text/html" scrolling="no" frameborder="0" style="border:0"></iframe></div>'
}
}
};
Related
I want to have one modal, only with content changing. In modal im showing articles via iframe. The problem is that my solution is a bit laggy, and you can see previous article before changing. Im using JS:
function switchTitleMod1(title,id) {
document.getElementById("titleMod1").innerHTML = title;
document.getElementById("iframe").src = "index.php?option=com_content&view=article&id="+id+"&tmpl=component";
}
The modal code:
<div id="informacje" class="uk-modal">
<div class="uk-modal-dialog" >
<a onclick="resetTitleMod1();" class="uk-modal-close uk-close"></a>
<div id="titleMod1" class="uk-modal-header uk-text-bold uk-text-large uk-text-center"><h2>Zapisz si? na kurs</h2></div>
<iframe id="iframe"style="width: 100%;height:650px" scrolling="auto" frameborder="0" src="index.php?option=com_content&view=article&id="34"&tmpl=component" hspace="0">
</iframe>
<div class="uk-modal-caption">Copyright by MRP-KODER</div>
This is how i call the modal:
<a onclick="switchTitleMod1('Szkolenia HACCP','42');" href="#informacje" data-uk-modal="{target:'#informacje',bgclose:false,center:true}" class="uk-button uk-button-medium uk-button-primary"> <i class="uk-icon-info uk-icon-justify"></i>Informacje</a>
My question is: How to create modal via Jquery and only adding deleting DOM. Link to the page: link
Via clicking "Informacje" You will see what the problem is.
I found solution by myself :) I didint use DOM model, but it works fine, for using diffrent modals only by changing button id.
var $jq = jQuery.noConflict();
$jq(document).on('click', '#info', open_info_modal).on('click', '#zapytaj', open_ask_modal);
function open_info_modal(e)
{
var articleId = $jq(e.target).data('id');
var articleTitle = $jq(e.target).data('title');
$jq('#modal').on({
'uk.modal.show':function(){
$jq('#title', $jq(this)).html('<h2>'+articleTitle+'</h2>');
$jq('span', $jq(this)).html('<iframe id="iframe"style="width: 100%;height:650px" scrolling="auto" frameborder="0" src="index.php?option=com_content&view=article&id='+articleId+'&tmpl=component" hspace="0">');
},
'uk.modal.hide':function(){
}
}).trigger('uk.modal.show');
}
function open_ask_modal(e)
{
var articleTitle = $jq(e.target).data('title');
$jq('#modal').on({
'uk.modal.show':function(){
$jq('#title', $jq(this)).html('<h2>'+articleTitle+'</h2>');
$jq('span', $jq(this)).html('<iframe id="iframe2"style="width: 100%;height:600px" scrolling="auto" frameborder="0" src="index.php?option=com_chronoforms5&chronoform=zapytaj-szkolenie&tmpl=component&name1='+articleTitle+'" hspace="0">');
},
enter code here'uk.modal.hide':function(){
}
}).trigger('uk.modal.show');
}
Looking to find how to define a variable to only the numbers "1214693" in console based on the url withing the iframe, I've tried "document." but I almost never use html nor javascript so I'm really unsure of how to go about this.
<iframe src="/build/upload?groupId=1214693" id="upload-iframe" frameBorder="0" scrolling="no" style="width:100%; height:175px; margin-left:10px"></iframe>
It's in the window object, not document.
Use this code in your iframe .html:
console.log(window.location.href)
and it will log the URL.
Then it is a simple matter to tokenize URL and extract data:
// thanks to http://stackoverflow.com/questions/11582512/how-to-get-url-parameters-with-javascript/11582513#11582513
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null
}
if (window.console) {
var idParam = getURLParameter('id');
console.log(idParam);
}
Not sure if this is what you're looking for but if you'd like the change the URL and have the id be parameterized then you'll want to do something like this:
<script type="text/javascript">
var id = 1214693;
$(document).ready(function() {
$('#iframe').attr('src', '/build/upload?groupId=' + id);
})
</script>
How can I get the value of flashvars attribute?
<embed src="http://wl2static.lsl.com/common/flash/as3/MemberApplet026.swf"
id="opera_elb" width="100%"
height="100%"
allowscriptaccess="always"
allowfullscreen="true"
bgcolor="ffe8ef"
quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash"
flashvars="muteaudio=0&ishd=1&ishq=0&twoway=0&proxyip=">
I am using getElementsByTagName to get the element.
var Em = content.document.getElementsByTagName('embed');
And replace values in flashvars
<script>
function myFunction()
{
var Em = content.document.getElementsByTagName('embed');
var str = Em[0].getAttribute('flashvars').innerHTML;
var res = str.replace("muteaudio=0","muteaudio=1");
document.getElementsByTagName("embed").innerHTML=res;
}
</script>
But when I try error: Uncaught ReferenceError: content is not defined
please help me.
Okay so here is a solution (strictly to change the attribute of flashvars!). First I think you have a few syntax errors within your JS. So I modified it and here is the JS:
function myFunction()
{
var Em = document.getElementById('vid');
var str = Em.getAttribute('flashvars');
var contentSpot = document.getElementById("he");
contentSpot.innerHTML = Em.getAttribute('flashvars');
Em.setAttribute('flashvars', 'muteaudio=1')
// contentSpot.innerHTML = Em.getAttribute('flashvars');/* I used this to see if the change occurred.*/
}
window.onload = myFunction();
So contentSpot is a div element I created to observe the change.
the html is here:
<embed id="vid" src="http://wl2static.lsl.com/common/flash/as3/MemberApplet026.swf"
id="opera_elb" width="100%"
height="100%"
allowscriptaccess="always"
allowfullscreen="true"
bgcolor="ffe8ef"
quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash"
flashvars="muteaudio=0&ishd=1&ishq=0&twoway=0&proxyip=">
<div id="he"> Hello</div> <!-- The created div to observe -->
Okay so here is my suggestion:
1)pop in the cleaned up code into a jsfiddle, then observe the content.
2)Then remove the line: contentSpot.innerHTML = Em.getAttribute('flashvars'); above the code: Em.setAttribute('flashvars', 'muteaudio=1').
3) remove comments slashes and then hit ctrl + enter to observe the attribute change.
*really watch your "."/DOM syntax and case sensitivity.
Hope this helps you out!
I have a string
str = '<iframe width="100%" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=vi&geocode=&q=Vimcom+91+b%C3%A0+tri%E1%BB%87u&aq=&sll=15.125395,108.795111&sspn=0.034096,0.038581&ie=UTF8&hq=Vimcom+91+b%C3%A0+tri%E1%BB%87u&hnear=&radius=15000&t=m&ll=21.011605,105.849323&spn=0.048074,0.051498&z=13&output=embed"></iframe><br /><small>Xem Bản đồ cỡ lớn hơn</small>'
How to get attr src using javascript (no-jquery) from str string?
Thank!
try this:
str.match(/.*src="([^"]+).*/)[1]
You can do this:
var str = '<iframe width="100%" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=vi&geocode=&q=Vimcom+91+b%C3%A0+tri%E1%BB%87u&aq=&sll=15.125395,108.795111&sspn=0.034096,0.038581&ie=UTF8&hq=Vimcom+91+b%C3%A0+tri%E1%BB%87u&hnear=&radius=15000&t=m&ll=21.011605,105.849323&spn=0.048074,0.051498&z=13&output=embed"></iframe><br /><small>Xem Bản đồ cỡ lớn hơn</small>';
var div = document.createElement('div');
div.innerHTML = str;
alert(div.childNodes[0].getAttribute('src'));
http://jsfiddle.net/Dogbert/hxjpB/
Make sure the string starts with the <iframe> or the first childNode would be a textNode, and this wouldn't work. (There are more robust ways to do this which would work in those cases too, if you want.)
You may find interesting using regular expressions on your code: http://www.w3schools.com/jsref/jsref_obj_regexp.asp and http://www.w3schools.com/js/js_obj_regexp.asp
This regex should work:
/src="[^\ ]*"/i
Lets say I have a function like this:
<script type="text/javascript">
function ReturnURL()
{
var url = document.URL;
var url2 = url.split("=");
var urlID = url2[url2.length-1];
//window.open('http://localhost/POSkill/skillshow.aspx?user_id =' + urlID);
return urlID;
}
</script>
And I also have iframe in my html file which is something like below:
<iframe id="showSkill" scrolling="yes" src="http://localhost/POSkill/skillshow.aspx?user_id = ReturnURL()" height="350" runat="server" ></iframe>
Now all I want to do is to send the urlID value of javasrcipt as the user_id value in iframe. I have tried by using user_id = ReturnURL() but its not working.
How can I do this?
Thanks in Advance.
I answered something very similar at enter link description here
The answer is that you must set the "src" value on the JS rendering.
This means that somewhere in your javascript you should have the following code
...
document.getElementById("showSkill").src="http://localhost/POSkill/skillshow.aspx?user_id =" + ReturnURL()
...
This should work just fine.