使用 greybox js 库使用 google tts 显示窗口

发布于 2024-11-04 23:58:19 字数 974 浏览 0 评论 0原文

为了清晰起见,对此进行了编辑:

我有一个 Django 应用程序!

我想使用 google tts 来翻译我网页上的某些项目。现在我有一个 onclick,是的,我应该知道得更好,它从 Django 模板调用一个 javascript 函数,向它传递一个短语,该函数对其进行一些工作,插入逗号以获得​​更好的发音等。

我将 url 传递给灰框,它打开没问题,Firefox、chrome...等。在窗口中放置一个嵌入式媒体播放器(在本例中为 gnome 媒体播放器),这样它显然知道它是音频,但是声音不播放,这很奇怪,因为它在我之前的另一个设置中播放,使用相同的浏览器,但没有任何代码更改。

以下是我的函数中对灰盒函数的调用:

return GB_showCenter(caption, "http://translate.google.com/translate_tts?tl=en&q=I hate programming, don't you?");

现在,如果您采用相同的 url 并将其直接放入浏览器地址栏中,它将起作用。同样的调用也可以在非 DJANGO 模板中工作,例如,如果我有来自直接 Html 文件的相同标签和相同的 onlcik,它就可以工作......

我在 Linux Mint 中使用 Firefox 4,但在Opera 11.10 和 Chrome。

有什么想法吗?也许与缓存有关?

谢谢

​我也尝试了以下内容,但同样,无法播放。

window.open(url,caption,'width=400,height=200,toolbar=0,location=0,directories=no,status=0,menubar=0,scrollbars=n0,copyhistory=no,resizable=0');

更新:如果我在普通浏览器窗口中使用该链接,然后单击灰盒链接,它就可以工作。我假设因为该文件在缓存中......

EDITED THIS FOR CLARITY:

I have a Django app!

I want to use the google tts stuff for translation of certain items on my web page. Now I have an onclick, yes I should know better, that calls a javascript function from a Django template, passing it a phrase, which the function does some work on, inserting commas for better pronounciation etc.

I pass the greybox the url and it opens no problem, Firefox, chrome...etc. place an embedded media player (gnome media player in this case) in the window so it obviously knows it is audio, however the sound doesn't play, which is odd as it played in another setup I had previously, with the same browsers without any code changes.

Here is the call to the greybox function from within my function:

return GB_showCenter(caption, "http://translate.google.com/translate_tts?tl=en&q=I hate programming, don't you?");

Now if you take the same url and put it straight into the browser address bar it will work. Also the same call will work from a NON DJANGO TEMPLATE, e.g. If I have the same tag with the same onlcik from a straight Html file, it works....

I am using Firefox 4 in Linux Mint, but it is the same in Opera 11.10 and Chrome.

Any ideas? Is it something to do with cache perhaps?

Thanks

p.s. I also tried it with the following but the same, doesn't play..

window.open(url,caption,'width=400,height=200,toolbar=0,location=0,directories=no,status=0,menubar=0,scrollbars=n0,copyhistory=no,resizable=0');

UPDATE: If I use the link in a normal browser window, and then I click the greybox link it works. I am assuming because the file is in cache...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

诗化ㄋ丶相逢 2024-11-11 23:58:19

您的网址有缺陷:

return GB_showCenter(caption, "http://translate.google.com/translate_tts?tl=en?q=I hate programming, don't you?");

“en”后不应有问号,而应有“&”符号:

return GB_showCenter(caption, "http://translate.google.com/translate_tts?tl=en&q=I hate programming, don't you?");

而且,不,我喜欢编程。

Your URL is flawed:

return GB_showCenter(caption, "http://translate.google.com/translate_tts?tl=en?q=I hate programming, don't you?");

Should not have a question mark after "en", but an ampersand:

return GB_showCenter(caption, "http://translate.google.com/translate_tts?tl=en&q=I hate programming, don't you?");

And, no, I love programming.

信仰 2024-11-11 23:58:19

好吧,最后,使用灰盒无法解决这个问题。做了一些实验,发现 lightwindow 是一个更好的选择。然而,它有点重,并且依赖于prototype.js库和一些其他文件,所以我正在考虑我的选择,以及最小化客户端上传负担的巧妙方法,包括javascript和所有日益广泛的CSS内容。但是,为了制作这个相当简洁的小语音模块的原型,lightwindow 可以完成这项工作。另外,我认为 grebox 目前没有得到维护,所以这将是一个挑选骨头并重写的问题。如果有必要的话,我宁愿从头开始。

Ok, so finally, no solution to this problem using greybox. Did some experiments and found lightwindow to be a better option. However, it is a tad heavy and realies on prototype.js library and a coupel of other files, so I'm considering my options, and neat ways to minimise the clients upload burden visa ve javascript and all the increasingly extensive CSS stuff. But, for the purposes of prototyping this rather neat little speech module, lightwindow does the job. Also, I don't think grebox is currently being maintained, so it would be a question of pick the bones and re-write. This is something I would rather start from scratch if it is neccesary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文