Page 1 of 1
Trapping URL from button click in a Blog object
Posted: Mon Aug 31, 2020 11:27 pm
by alex4orly
I am going to a major remake of this website, as an example - please see this page :
http://www.nmaa-rc.org.au/videoclips.html
On the right hand side column (Layout grid) is a Blog object with many options.
Clicking any of them, brings up a page in the left hand side column, inside an iFrame
How can I trap, the blog entry "Button" click and get its intended link / url - in Javascript
I have many other pages, in this website and other sites with this setup, and I am forced to re-buld it
Looking forward to some help
Thanks
Re: Trapping URL from button click in a Blog object
Posted: Tue Sep 01, 2020 6:06 am
by Pablo
Re: Trapping URL from button click in a Blog object
Posted: Tue Sep 01, 2020 6:25 am
by alex4orly
Yes, this helps.
I figured the 1st half already, I was missing the 2nd part which the above link answered
document.getElementById("Blog2").addEventListener("click", function(){
alert(Blog2);
});
"Blog2" is the elemnt ID of the entire blog object.
It seems that in QWB, the object itself doesn't have the "Enets" menubar, it is dissabled - why? So, I inserted it into the Page HTML.
Or is it the wrong way about it? In the Object itself, where can I insert this?
In my case, this object is sitting on it's own html page, that page is then embeded inside the main page.
Will the setup "Find" the iFrame, which is in the main parent page?
Thanks
Re: Trapping URL from button click in a Blog object
Posted: Tue Sep 01, 2020 7:07 am
by Pablo
Unfortunately, I cannot help you with coding related questions.
For me, it may also take a lot of time to figure out how to implement this.
Re: Trapping URL from button click in a Blog object
Posted: Tue Sep 01, 2020 10:41 pm
by alex4orly
OK, I followed the link and created a new page :
http://www.nmaa-rc.org.au/page9.html
It has in it a single example, the Blog object is part of the page, NOT embeded like I had it originally
The following is the function:
<script>
document.addEventListener(`click`, e => {
const origin = e.target.closest("a");
if (origin)
{
var clicked = origin.href;
window.frames[0].location = clicked;
}
});
</script>
When you click on the button "Click to view" , it goes at first to show the clip in the iFrame on the left, then it opens a new browser page and moves to it. If you hit the back button in the browser - you can see that in the original page, the video is in the iFrame ready to be played.
Any suggestion, why does it do that? It has to do something with this? e.target.closest("a"); What is this command?
Thank yoy
Re: Trapping URL from button click in a Blog object
Posted: Wed Sep 02, 2020 1:13 am
by BaconFries
Hi Alex just a suggestion that's all wouldn''t it be simpler to use the YouTube playlist method? See the following examples:
Demo Codepen
https://codepen.io/derwinsadiwa/pen/obbjdx
And
https://woosterwebdesign.com/responsive ... -playlist/
Just a suggestion but I realise you do like playing about with script to do what you require.
Re: Trapping URL from button click in a Blog object
Posted: Wed Sep 02, 2020 2:05 am
by alex4orly
Long time no hear... Hope all is well at your end.
My use of this method is NOT restricted to YT clips, see this as an example :
http://www.nmaa-rc.org.au/howto.html
Or this :
http://www.nmaa-rc.org.au/rclinks.html
So, as you can see, my "Play-list" is generic way, not only for YT, hence - I must find a solution for all other cases.
Thanks for the links, I may have use for it in some cases.
In the meantime- my problem is resolved - I just added into the parent page and Event trigger
Onclick->Show->InlineFrame1 , this forces the action to take place where it needs to be
This little extra with the above code sample.
Thanks again
Re: Trapping URL from button click in a Blog object
Posted: Wed Sep 02, 2020 4:56 pm
by BaconFries
Hi Alex Doing ok here, I was under lockdown and shielding, this meant staying at home from the 23rd of March and only came to a end from the 1st of August. I hope all is well with you down under. Good to hear you have it working now. Right of to get a bite to eat and possibly a wee dram
or 2.
Re: Trapping URL from button click in a Blog object
Posted: Fri Sep 04, 2020 8:48 am
by alex4orly
Hello again,
Easy on the beer... Take care of yourself
My exercise of moving to Linux, turned out a real nightmare, to say the least. Yesterday, while at it, I had no computer at all, trying to use the entire storage device to install Linux, it wiped the Windows partition and I had nothing...
At the moment, I am able to access this forum but NOT the QNE forum
Cheers
Alex